Display Custom Post Type in theme

  • Post count: 40
    March 21, 2016 at 4:17 pm #19179


    I’m using the CustomPostType UI plugin to organize a site. The plugin does not handle display of registered post types in theme. It simply helps me register them.
    I [really] need to be able to display these posts I’ve been creating on pages [using categories on blog masonry layout].
    As your section portfolio is a custom post type, I would like to know how can I display the ones I’ve registered.
    I’ve checked your themes-functionality.php, but don’t want to touch anything unless I am sure.
    Tried to add the following code in jkreativ-child functions.php
    add_filter( ‘pre_get_posts’, ‘my_get_posts’ );

    function my_get_posts( $query ) {

    if ( is_home() && $query->is_main_query() )
    $query->set( ‘post_type’, array( ‘davidcarreiro’, ‘agostinofaggiano’) );

    return $query;

    Let me know how can I manage it! 🙂
    Hope this is clear enough, if not feel free to ask me,

    Thanks a lot

    Post count: 40
    March 22, 2016 at 7:52 pm #19215

    Hello again,

    so, this plugin is making more troubles that I want on your theme 🙂
    So the best way to manage what I want to do, is would be coding directly the custom post type that I want to display and that works like Posts.
    So, first question, if I use only the child theme functions.php it should work right? But the main question is, will my loop be able to display my custom post type on my site pages like the traditional Posts (and using categories to display on pages)?
    For example with this code :
    add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ );

    function add_my_post_types_to_query( $query ) {
    if ( is_home() && $query->is_main_query() )
    $query->set( ‘post_type’, array( ‘davidcarreiro’, ‘agostinofaggiano’ ) );
    return $query;

    If you also can tell me, in which file I can have a look to the get_post code (I’ve looked to the portfolio one but it’s doesn’t help cause, portfolio is also a Page template).
    I just wanna know how I can manage to display custom post type on blog masonry page 🙂

    Thank you so much for your help

    Post count: 10705
    March 24, 2016 at 4:59 am #19306

    Hi iuliacc,

    You can use child theme on this thing. So when you’re going to update your theme version your changes file will not lost.

    Unfortunately this is not our support scope but we will try to help you as long as we can. Anyway you can try to take a look on single portfolio and portfolio page list to know how we manage custom post type.

    Thank you

You must be logged in to reply to this topic.