Query / Loop for Custom Post Type AND Page Content
-
Hello,
I can’t find the solution for displaying my custom post type and the page content. I would like to display at first the content of the regular wordpress page and after that, I would like to display a portfolio (for example) with the custom post types:
At first I registered the custom post type in the functions.php – no problem. Then I created a page-template with a CPT-Loop.
<?php /** * Template Name: Portfolio * The template for displaying portfolio posts. * * @package blalba */ get_header(); ?> <div id="primary" class="content-area col-md-9"> <main id="main" class="site-main" role="main"> <?php $args = array( 'post_type' => 'portfolio', 'posts_per_page' => 9 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?> <?php endwhile; // end of the loop. ?> </main><!-- #main --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer(); ?>
My Question: How should I code the loop / query to display both (CPT and Page Content)? I found in the WP Codex a multiple Loop… but it doesn’t work for me.
Thanks,
David
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Query / Loop for Custom Post Type AND Page Content’ is closed to new replies.