Display Custom Post Type in homepage

  • Author
    Posts
  • #131897

    Hi! We’re using the Roseta theme and we got some trouble triyng to display in home page in the box using this class “lp-boxes lp-boxes-2 lp-boxes-animated lp-boxes-rows-4” the custom post type “servizi” we’ve created.

    We have brought in the child-theme the includes/landing-page.php same of the parent, modifiyng only the:

    $args = apply_filters( ‘roseta_boxes_query_args’, array(
    ‘showposts’ => $options[‘theme_lpboxcount’ . $sid],
    ‘cat’ => cryout_localize_cat( $cat ),
    ‘ignore_sticky_posts’ => 1,
    ‘lang’ => cryout_localize_code(),
    ‘post_type’ => array(‘servizi’, ‘post’),
    ), $options[‘theme_lpboxcat’ . $sid], $sid );

    Adding “servizi” in the post_type but if we do it in the parent theme everything is ok and it works, nothing happen if we do it in the child.

    Can you gently help us? How can we fix this in the child theme preventing theme update future problems?

    #134790
    Zed
    Cryout Creations mastermind

    Hi,

    It would be a better idea to not customize the landing page file at all and simply make use of the existing filter to override the query arguments, for example:

    function child_boxes_override( $args, $section_status, $section_id ) {
       // apply for second boxes section only 
       if ( $section_id == 2 ) { 
             // do you want to include both the custom post type and regular posts?
             $args['post_type'] = array( 'servizi', 'post' ); 
       }
       return $args;
    }
    apply_filters( 'roseta_boxes_query_args', 'child_boxes_override', 10, 3 );

    All arguments used in this filter are passed to the posts query.


    If you like our creations, help us share by rating them on WordPress.org.
    Please check the available documentation and search the forums before starting a topic.
Viewing 2 posts - 1 through 2 (of 2 total)

You need to log in to reply to this topic.