Home Forums Front-end Issues Build a menu from from multiple custom posts


Build a menu from from multiple custom posts

  • I have a custom post type called products.
    Each product has an “is_featured_product” True/False field.

    I now need to be able to create a menu out of these Featured Products in a template.

    Other than using <p><?php the_field(‘field_name’, 123); ?></p> to get posts from another page, is there a way to get all the fields marked as true from all my products?


  • Solution if anyone is look for it, managed to figure it out.

    	$args = array(													
    	'post_type' => 'product', 
    	'posts_per_page' => -1, 
    	'orderby' => 'title', 
    	'order' => 'ASC',
    	'meta_query' => array(
    	           'key' 		=>	'is_featured_product',
    <?php $loop = new WP_Query( $args ); ?>
    <div class="nav subnav">
    	<ul id="menu-top-ten-product-menu" class="menu">
    		<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
    				<a href="<?php the_field('product_logo'); ?>">
    					<img src="<?php the_field('product_logo'); ?>" alt="">
    		<?php endwhile; ?>
    		<?php wp_reset_query(); ?>
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.