Ответы в темах

Просмотр 15 ответов — с 61 по 75 (всего 131)
  • сделал так:

    
    // количество товара на странице 80/100/160
    
    function my_select(){
        $s         = filter_input(INPUT_GET,'s',FILTER_SANITIZE_STRING);
        $post_type = filter_input(INPUT_GET,'post_type',FILTER_SANITIZE_STRING);
    
        echo "<form class='woocommerce-perpage' method='get'><span>Products per Page:</span>";
        if ($s) {
            echo "<input type='hidden' name='s' value='$s' />";
        }
        if ($post_type) {
            echo "<input type='hidden' name='post_type' value='$post_type' />";
        }
        echo "<select onchange='this.form.submit()' name='select_page'>";
        $orderby_options = array(''=>'','40'=>'40','60'=>'60');
        foreach($orderby_options as $key=>$value){
            echo "<option  value='$value'>$value</option>";
    
        }
        echo "</select></form>";
    }
    
    add_action('pre_get_posts','ga_pre_get_products_query');
    function ga_pre_get_products_query($query){
        $per_page = filter_input(INPUT_GET,'select_page',FILTER_SANITIZE_NUMBER_INT);
        global $wp_query;
        if($query->is_main_query() && !is_admin()  ){
            $query->set('posts_per_page',$per_page);   
    
        } 
    
    }
    
    // end количество товара на странице
    
    
    <div class="selectPage"><span class="prosmotrTovara blueSort">Просмотр товара</span>
     <a href="/shop/?select_page=40">40</a>/
     <a href="/shop/?select_page=60">60</a>/
     <a href="/shop/?select_page=100">100</a>
      шт.</div>
    

    спасибо! похоже.. но конфликтный зараза… и старый..

    может jquery плагин какой-то подобрать и внедрить…?

    эти плагины для записей.. мне нужно переход по страницам без перезагрузки… и было бы не плохо с какой-то анимацией…

    тема Generatepress // щас попробуем… спасибо.

    спасибо!

    Спасибо! мне не это нужно.. а что-то вроде get_the_post_navigation

    приветствую! я делаю так: ставлю Popup Maker (он интегрируется с contact form7) , там создаю всплывающее окно типа Спасибо, потом в contact form 7 в форме выставляю что после успешной отправке вылезает это «спасибо»…

    это понятно… при выводе ошибки нужно как-то класс добавить инпуту (как же тогда показать что не прошел код) , как кнопке купить добавляется класс когда товар добавлен в корзину.. а он так и остается без изменений…

    пытаюсь пагинацию сделать

    
    <?php
    $post_type = 'doctor';
    $taxonomy = 'nosology';
    
    // count the number of terms for correct pagination
    $term_count = get_terms( array (
        'taxonomy' => $taxonomy,
        'fields'   => 'count',
    ) );
    
    // define the number of terms per page
    $terms_per_page = 3;
    
    // find out the number of pages to use in pagination
    $max_num_pages = ceil( $term_count / $terms_per_page );
    
    // get the page number from URL query
    $current_page = get_query_var( 'paged', 1 );
    
    // calculate the offset, if there is one.
    $offset = 0; // initial
    // or changed the if not the first (0)
    if( ! 0 == $current_page) {
        $offset = ( $terms_per_page * $current_page ) - $terms_per_page;
    }
    
    // get all taxonomy terms
    $terms = get_terms( array (
        'taxonomy' => $taxonomy,
        'order'    => 'ASC',
        'orderby'  => 'name',
        'number'   => $terms_per_page,
        'offset'   => $offset,
        'hide_empty' => 1,
    ) );
    
    // cycle through taxonomy terms
    foreach ( $terms as $term ) {
    
        echo '<h3 class="titleListSlider">' . $term->name . '</h3>';
        // cycle through posts having this term
        $items = get_posts( array (
            'post_type'   => $post_type,
            'tax_query'   => array(
                array(
                    'taxonomy' => $taxonomy,
                    'field'    => 'slug',
                    'terms'    => $term->slug,
                ),
            ),
            'numberposts' => -1, // different from WP_Query (see Code Ref)
        ) );
    
        // essential, see comments inside foreach() loop
        global $post;
    
        foreach ( $items as $item ) {
    
            // assign $item to global $post 
            $post = $item;
            // and now set up 
            setup_postdata( $post );
    
     ?>
    
      <div class="index-b-4-t rowVrach">
         <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>                                                
      </div>
    	
    
    <?php  }
        wp_reset_postdata();
        // end posts cycle
     }
    // end term cycle
    
    // Pagination
    echo paginate_links( array (
        'total'   => $max_num_pages,
        'current' => $current_page,
    	'show_all'     => false,
    	'end_size'     => 2,
    	'prev_text'    => __('« '),
    	'next_text'    => __(' »'),
    ) );
    
    $big = 999999999; // need an unlikely integer
    
    echo paginate_links( array(
    	'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    	'format' => '?paged=%#%',
    	'current' => max( 1, get_query_var('paged') ),
    	'total' => $wp_query->max_num_pages
    ) );
    
    ?>
    

    так он читает все термы и выводит их, если я добавлю выборку
    …..
    foreach ( $terms as $term ) {
    $query = new WP_Query( array(
    ‘post_status’ => ‘publish’,
    ‘post_type’ => ‘doctor’,
    ‘posts_per_page’ => -1,
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘nosology’,
    ‘field’ => ‘slug’,
    ‘terms’ => $term->slug,
    )
    )
    ));
    if ( ! $query->have_posts() ) continue;
    echo ‘<h3 class=»titleListSlider»>’ . $term->name . ‘</h3>’;
    // cycle through posts having this term
    …..`
    `
    то оно не правильно выводит по 3 на страницу, т.е. цикл выводит правильно по 3 на страницу, но если пропускает терм, то 1 или 2 получается….

    круто! спасибо большое!

    а как поступить тогда?

    такое впечатление что первый проход цикла это пропускает, потому-что что все остальное пустое не выводится и там есть другие записи

    в выборке указано же ‘post_type’ => ‘doctors’

    • Ответ изменён 6 лет, 8 месяцев назад пользователем face2005.
    • Ответ изменён 6 лет, 8 месяцев назад пользователем face2005.

    дело в том что выводится пункт терма в котором нет этих записей, и он, соответственно пустой, а в аргументах есть ‘hide_empty’ => 1..
    вот страница https://test-sait.pp.ua/doctors/

    сделал так: создал шаблон архива archive-services.php и сделал его шаблоном страницы
    Template Name: Шаблон Сервис архив … вроде схавало…

Просмотр 15 ответов — с 61 по 75 (всего 131)