WordPress.org

Ready to get started?Download WordPress

Forums

How to Show All Post Types (22 posts)

  1. jaeeun
    Member
    Posted 1 year ago #

    Hi,

    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;

    http://www.parabolastudio.com/

    Currently the front is a static page.

    Thank you!!!

    Jaeeun

  2. mbrsolution
    Member
    Posted 1 year ago #

    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?

  3. jaeeun
    Member
    Posted 1 year ago #

    Hi mbrsolution,

    Thanks for responding to my post.

    What I want to do is actually something like this;

    http://www.eladian.com/

  4. mbrsolution
    Member
    Posted 1 year ago #

    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.

    Example:

    <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.

    Kind regards

  5. jaeeun
    Member
    Posted 1 year ago #

    Thanks you- but I've set it to my latest post and nothing shows up...!

    http://www.parabolastudio.com/

  6. mbrsolution
    Member
    Posted 1 year ago #

    Can you tell me how many post you have published? Can you also let me know your settings?

  7. jaeeun
    Member
    Posted 1 year ago #

    I've posted four- three under Portfolio, and the Contact post. Which settings should I let you know of?

  8. mbrsolution
    Member
    Posted 1 year ago #

    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

    Kind regards

  9. mbrsolution
    Member
    Posted 1 year ago #

    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?

  10. tiaanswart
    Member
    Posted 1 year ago #

    You will need to create a wp_query that displays all of your custom post types at once, review the wp_query docs:

    http://codex.wordpress.org/Class_Reference/WP_Query

  11. jaeeun
    Member
    Posted 1 year ago #

    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...!

  12. tiaanswart
    Member
    Posted 1 year ago #

    did you introduce a new loop with your query?

  13. jaeeun
    Member
    Posted 1 year ago #

    This is how my home.php looks now;

    http://pastebin.com/bg3S2z3T

  14. mbrsolution
    Member
    Posted 1 year ago #

    Check your code? See example below.
    $query = new WP_Query( array( 'post_type' => array( 'post', 'page', 'movie', 'book' ) ) );

  15. tiaanswart
    Member
    Posted 1 year ago #

    try this:

    <?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('&laquo; Older Entries'); ?></span>
            <span class="newer"><?php previous_posts_link('Newer Entries &raquo;'); ?></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(); ?>
  16. jaeeun
    Member
    Posted 1 year ago #

    I tried it replacing the names of post types to my own, but... ;

    http://www.parabolastudio.com/

  17. tiaanswart
    Member
    Posted 1 year ago #

    please paste the below line underneath the query code:

    <?php print_r($wp_query);?>

  18. jaeeun
    Member
    Posted 1 year ago #

  19. tiaanswart
    Member
    Posted 1 year ago #

    As you can see the query did not find any posts:

    [found_posts] => 0

    Please check your custom posts if they are published

  20. tiaanswart
    Member
    Posted 1 year ago #

    also please remove the below line again:

    <?php print_r($wp_query);?>

  21. jaeeun
    Member
    Posted 1 year ago #

    I wonder if there's something wrong with my custom post type settings. A post in the default Posts type shows up. But if you click it you go to a custom post type page, which is "Portfolio."

  22. jaeeun
    Member
    Posted 1 year ago #

    The wrong link problem was because it was categorized as "portfolio."

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags