How to add custom post type to wordpress menu

How to add custom post type to wordpress menu

WordPress tutorial, for developer, Many people wondering How to add custom post type to wordpress menu. Best idea is first create page with custom post type.

For example you created custom post type art then you need to create page name with art. Then create template with name of art.

How to add custom post type to wordpress menu

Add following code in that file.

<?php /* Template Name: Art */
$loop = new WP_Query( array( 'post_type' => 'art', 'posts_per_page' => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
the_content();
global $post;
$custom = get_post_custom($post->ID);
echo '<div>';
the_content();
echo '</div>';
endwhile;
?>

Than open your appearance-Menu and add the Art page in navigation or main menu.

Using this trick you can easily add the custom post type in wordpress navigation.

How to add custom post type to wordpress menu
How to add custom post type to wordpress menu

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

One thought on “How to add custom post type to wordpress menu”

Leave a Reply

Your email address will not be published.