• Resolved Ghostwise_

    (@ghostwise_)


    Hello,

    Probably a silly question since I’m a newcomer to WordPress…

    I have a custom posts type called post_news

    The index.php of the site I’m trying to build displays the usual list of recent posts with what seems to be the usual bit (“The Loop”, apparently) :

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    I’m trying the have my custom post_news posts displayed along with the basic posts in this loop.

    My best try so far, in the function.php of the theme, produces no results :

    function add_news($query) {
      if ( !is_home() && $query->is_main_query() ) {
          $query->set('post_type', array( 'post', 'post_news' ) );
        }
      }
    
    add_action('pre_get_posts','add_news');

    Any advice ? Thanks !

    https://wordpress.org/plugins/wck-custom-fields-and-custom-post-types-creator/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Adding custom posts to The Loop’ is closed to new replies.