• Resolved Robert

    (@robg48)


    Hello,
    I’m not sure if this is a WP issue or a plugin issue but I’ve created a bunch of Custom Posts using WP-Types.

    The issue is I have WP setup to display my “last 10 posts” on my home page – and nothing is being displayed because my last 10 posts were all created using the WP-Types Custom Post types.

    Is there a way to get WP to recognize those custom post types as “regular” WP Posts?

    Robert

Viewing 5 replies - 1 through 5 (of 5 total)
  • jack randall

    (@theotherlebowski)

    you’ll need to create a new page called home, then create a new template for that page and include a custom loop that queries the database for your custom post type and apply that template to your new home page. then in settings -> reading, select your home page as a static front page.

    if none of that made sense to you then you may be facing a fair old mountain to climb!

    Thread Starter Robert

    (@robg48)

    Hey Jack – thanks for the response! And it’s all a mountain ??

    I get most of it…but it’s not just the front page…I have themes I use that display “the top 10…the most viewed…the highest rated…” etc…and it seems those are not getting recognized by WP because they’re custom post types.

    jack randall

    (@theotherlebowski)

    yeah, in order for wordpress to recognise them you have to tell it to go look for them, the custom post type is created and added to the database but until you actually call the database and ask for the content nothing happens.

    make a backup of your site just as you’ll be making tweaks to files. also, if you’re not using a child theme, now’s a perfect time to set one up!

    take your parent theme’s page.php file and copy it over to your child theme (i hope you’re using a child theme!) and rename it page-(insert your custom post type name here).php and change the header (the bit in the /** **/ at the top of the file) to read

    /*
    Template Name: (call it what you want)
    */

    next, apply this template to the page you’re using for the home page and save your changes.

    next up, you need to create a custom loop to call the database and then add in some php to show the results on the front end.

    <?php $args = array('post_type' => 'name_of_post_type');
                $query = new WP_Query($args);
    
                while( $query->have_posts() : $query->the_post() );
    
    ?>
    
    html goes here...
    
    <?php echo types_render_field( 'field_name', array( 'output' => 'raw' ) ); ?> 
    
    end of your html...
    
    <?php endwhile; ?>

    it’s a bit of a steep curve but it’s worth it with the cool stuff you can do with custom post types. keep referring to the types by toolset website and the wordpress codex for more information on how to get this done.

    Thread Starter Robert

    (@robg48)

    Hi Jack,

    Thanks for the info – doesn’t look too hard ??

    I appreciate the time!
    Rob

    jack randall

    (@theotherlebowski)

    no worries, good luck and enjoy playing about with it ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Have WP recognize custom post types?’ is closed to new replies.