• Hello!

    I’m using a theme called Paperback (demo)

    This theme has a mega drop-down navigation that shows 6 latest posts under each category (if the menu link selected is a category). Currently it shows this mega drop-down for normal posts only.

    I have a custom post type called “case-study”. How can I get the mega drop down to also include posts from custom post type along with normal posts?

    Here is the php template code for the nav drop down:
    https://pastebin.com/CzKDkuSS

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Just replace your below code :

    <?php
                    wp_get_archives(
                        array(
                            'type'   => 'monthly',
                            'limit'  => '6',
                            'format' => 'custom',
                        )
                    );
                ?>

    with :

    <ul>
    	<?php
    	$args = array(
    		'post_type'=>array('post','case-study'),
    		'posts_per_page'=>6,
    		'orderby' => 'date',
    		'order'   => 'DESC',
    		);
    	$query = new WP_Query($args);
    	if($query->have_posts()): while($query->have_posts()): $query->the_post();
    	?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    	<?php
    	endwhile; endif; wp_reset_postdata();
    	?>
    </ul>

    Thread Starter vlvgfx

    (@vlvgfx)

    Hi Gorakh.sth

    I tried that but it didn’t seem to work. The code you indicated to replace seems like it’s from the sidebar/footer.

    So I was referring to the primary dropdown navigation. Where if you click on a section, it shows a dropdown with 6 of the latest posts in it of that particular category.

    I would like to have custom post types (of the same category) also appear inside that drop down alongside normal posts.. Any thoughts?

    Hi vlvgfx,

    It seems like you have given wrong file on pastebin, because as we inspect element from firbug when we click on category in top navigation, the 6 posts which are coming below that have div class=”featured-posts clear show” and in drop down nav file there is nothing like that. Is this a premium theme ? have you asked this from theme author ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show Custom Post Types entries in Category DropDown’ is closed to new replies.