How to Show All Post Types
My wordpress site has custom post type (about, portfolio, contact) and I’d like to know if there’s a way to show all the post types and their contents in one page.
My website is;
Currently the front is a static page.
Hi jaeeun, you say your site is static but then you also mention that you have some post type (about, portfolio, contact).
I was wondering if you wanted to create a blog? Your post type should be pages and then you can create some post which will become your blog.
The post will be dynamic and the pages static.
Is that what you want to do?
Thanks for responding to my post.
What I want to do is actually something like this;
I see what you want.
You will have to set your wordpress to your latest post. Then you will have to create a menu with links to each post. Those links will be anchor links.
<a name="TOC">Table of Contents</a>
To link to the anchor above you’d code your link like this:
<a href="#TOC">Table of Contents</a>
I hope this helps you.
Thanks you- but I’ve set it to my latest post and nothing shows up…!
Can you tell me how many post you have published? Can you also let me know your settings?
I’ve posted four- three under Portfolio, and the Contact post. Which settings should I let you know of?
I have created 2 post using the default theme Twenty Eleven. I have published both post.
I have my WordPress set to the latest post and I see both post there on the front page.
I have also created 4 pages. The pages are added to the top menu and the side menu.
Have a look at my link
If you have developed your own them then you might be missing some code on the default page “home page” that is why your post are not showing.
If you use the default theme Twenty Eleven you will see that the post will be published to the front page following my settings above.
You can also copy that code and use it on your own theme to display the post on the front page.
Let me know what you think?
You will need to create a wp_query that displays all of your custom post types at once, review the wp_query docs:
I edited home.php as mbrsolution suggested, and now it shows the content box, which is good!
But it’s still empty… I looked into the codex page that tiaanswart posted and pasted this code with my custom post types in my home.php;
$query = new WP_Query( array( ‘post_type’ => array( ‘post’, ‘page’, ‘movie’, ‘book’ ) ) );
but no posts shows up…!
This is how my home.php looks now;
Check your code? See example below.
$query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'movie', 'book' ) ) );
<?php get_header(); ?> <?php get_sidebar(); ?> <div id="content" class="group"> <?php $query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'movie', 'book' ) ) ); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <!-- CUSTOM POST FORMATTING HERE --> <!-- POST START --><br/> <div class="post"> <!-- ENTRY START --> <div class="date"> <p>Posted on <span style="font-weight: bold;"><?php the_time( 'D d M Y ' ); ?></span> (about <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; ?>) by <span style="font-weight: bold;"><?php the_author_link(); ?></span></p> </div> <div class="entry"> <h2 class="title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> </div> <!-- ENTRY END --> </div> <!-- POST END --> <?php endwhile; ?> <?php if(($wp_query->found_posts) > (get_option('posts_per_page'))) :?> <!-- Page Navigation --> <?php if (function_exists('wp_pagenavi')) : ?> <div class="pagenavi"> <?php wp_pagenavi(); ?> </div> <?php else : // Use WordPress default page navigation. ?> <div class="pages"> <span class="older"><?php next_posts_link('« Older Entries'); ?></span> <span class="newer"><?php previous_posts_link('Newer Entries »'); ?></span> </div> <?php endif; ?> <?php endif; ?> <?php else : ?> <p>Sorry, but nothing matched your search criteria.</p> <?php get_search_form(); ?> <?php endif; ?> </div> <!-- END main-content --> <?php get_footer(); ?>
- The topic ‘How to Show All Post Types’ is closed to new replies.