Forum Replies Created

Viewing 3 replies - 151 through 153 (of 153 total)
  • @sonny12,
    try this code and give me output here.

    
    $field_key = "your_field_name";
    $field = get_field_object($field_key);
    

    so that i could help you more.

    Hi @sonny12,
    @bcworkz is right here you will have to pass meta_value to get posts by meta_key.
    you could do it with meta_query we have in wp_query.
    try this code and if it works let me know.

    
    $args = array(
    	'post_type'     => 'product',
    	'post_per_page' => -1,
    	'meta_query' => array(
    		array(
    			'key'     => 'product_family',
    			'value'   => array( 'latest', 
    					'car_navigation', 
    					'thired_one'),
    			'compare' => 'IN',
    		),
    	),
    );
    
    $query = new WP_Query($args);
    
    $count = $query->post_count;
    
    echo '<p>' . $count . '</p>';
    

    Hi @beyondthelamppost,
    you can try this code on your tag page template and please don’t forget to change test code and class from this code.
    Let me know if it not work for you.

    
    <div class='your_tag_container'>
    	<div class='your_entries_container'>
    		<h3>Entries</h3>
    		<?php 
    		$query = new WP_Query( ‘post_type=entries’, 'tag' => 'cooking'); 
    		if ( $query->have_posts() ):
    			while ( $query->have_posts() ) : $query->the_post();
    				// here your enties content will come
    			endwhile; 
    			wp_reset_postdata();
    		endif;
    		?>
    	</div>
    	<div class='your_post_container'>
    		<h3>Blog Post</h3>
    		<?php 
    		$query = new WP_Query( ‘post_type=post,'tag' => 'cooking'); 
    		if ( $query->have_posts() ):
    			while ( $query->have_posts() ) : $query->the_post();
    				// here your post content will come
    			endwhile; 
    			wp_reset_postdata();
    		endif;
    		?>
    	</div>
    </div>
    
Viewing 3 replies - 151 through 153 (of 153 total)