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

Просмотр 3 ответов — с 1 по 3 (всего 3)
  • ну в этой строке типа условие, что если поле na_glavnoj =1 единице, то выводить запись !
    А чего в это строке не верно ?
    Передел так вот и заработало:
    <?php

    $args = array(
    ‘post_type’ => ‘post’,
    ‘posts_per_page’ => 8,
    ‘meta_key’ => ‘na_glavnoj’,
    ‘meta_value’ => 1
    );
    $query = new WP_Query($args);
    ?> <div class=»main_proj_gl»> <?php
    while ( $query->have_posts() ) {
    $query->the_post();
    ?>
    <div class=»post-announce»>
    <?php echo get_the_post_thumbnail(); ?>
    <h4><?php the_title(); ?></h4>
    <div class=»ppodr_dom_gl»>
    <div>цена за метр: от
    <?php get_field(‘price_for_metre’);?> <span> <?php the_field (‘price_for_metre’); ?></span>
    </div>
    <div>«>подробнее</div>
    </div>
    </div>
    <?php } ?>
    </div>
    </div>
    <?php wp_reset_postdata(); ?>

    если указано 5, то выводится 4 записи

    так если выводить объект $term то там нет данного поля оно не подцепляется почему-то.
    это в файле loop-start.php
    вот весь код…может как то надо подцеплять данное поле иначе ?

    <?php
    /**
     * Product Loop Start
     *
     * This template can be overridden by copying it to yourtheme/woocommerce/loop/loop-start.php.
     *
     * HOWEVER, on occasion WooCommerce will need to update template files and you
     * (the theme developer) will need to copy the new files to your theme to
     * maintain compatibility. We try to do this as little as possible, but it does
     * happen. When this occurs the version of the template file will be bumped and
     * the readme will list any important changes.
     *
     * @see         https://docs.woocommerce.com/document/template-structure/
     * @package     WooCommerce/Templates
     * @version     3.3.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    }
    ?>
    <?php
    $parentid = get_queried_object_id();
    $args = array('parent' => $parentid);
    $terms = get_terms( 'product_cat', $args );
    $category = get_queried_object(); // получаем id категории 
    $itog = $category->term_id;
    if ($itog === 193){
    	if ( $terms ) {
    	echo '<div class="categories_list categorypage brends clearfix">';
    		foreach ( $terms as $term ) {
    			echo '<div class="item">';
    			echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
    			?><div class="imgcat"><?php woocommerce_subcategory_thumbnail( $term ); ?></div><?php
    			echo '<span> '.$term->name.'</span>';
    			echo '</a>';
    			echo '</div>';
    		}
    		echo '</div>';
    	}
    }
    
    elseif ($itog === 20){
    		if ( $terms ) {
    	echo '<div class="categories_list categorypage seyfy clearfix">';
    		foreach ( $terms as $term ) {
    			echo '<div class="item">';
    			echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
    			woocommerce_subcategory_thumbnail( $term );
    			echo '<span> '.$term->name.'</span>';
    			echo '</a>';
    			echo '</div>';
    		}
    		echo '</div>';
    	}
    }
    
    elseif ($itog === 26){
    		if ( $terms ) {
    	echo '<div class="categories_list categorypage oruzheynye clearfix">';
    		foreach ( $terms as $term ) {
    			echo '<div class="item">';
    			echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
    			woocommerce_subcategory_thumbnail( $term );
    			echo '<span> '.$term->name.'</span>';
    			echo '</a>';
    			echo '</div>';
    		}
    		echo '</div>';
    	}
    }
    else
    if ( $terms ) {
    echo '<div class="categories_list categorypage clearfix">';
    foreach ( $terms as $term ) {
    echo '<div class="item">';
    echo '<a href="' . esc_url( get_term_link( $term ) ) . '" class="' . $term->slug . '">';
    woocommerce_subcategory_thumbnail( $term );
    echo '<span> '.$term->name.'</span>';
    echo '</a>';
    echo '</div>';
    }
    echo '</div>';
    }
    ?>
    <ul class="products tovaryvkategorii columns-<?php echo esc_attr( wc_get_loop_prop( 'columns' ) ); ?>">
    
    • Ответ изменён 3 года, 7 месяцев назад пользователем morgusha.
Просмотр 3 ответов — с 1 по 3 (всего 3)