Display post with include_once [closed]

0

I want to list all my posts of all my custom post type, until then I get list in index.php

But the problem is that it only lists one post for each custom post type.

My index.php loop

<?php $args = array('post_type'=>array('filmes', 'series', 'blog'),'paged' => $paged,'orderby'=>'date','posts_per_page' => 8); query_posts($args); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php   if (has_post_thumbnail()) {
    $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID),'home');
    $imgsrc = $imgsrc[0];
} elseif ($postimages = get_children("post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=0")) {
    foreach($postimages as $postimage) {
        $imgsrc = wp_get_attachment_image_src($postimage->ID, 'home');
        $imgsrc = $imgsrc[0];
    }
    } elseif (preg_match('/
        <img [^>]*src=["|\']([^"|\']+)/i', get_the_content(), $match) != FALSE) {
        $imgsrc = $match[1];
    } else {
        $imgsrc = get_template_directory_uri() . '/images/no-imagen.png';
    } ?>
<?php 
if ( get_post_type( get_the_ID() ) == 'filmes' ) {
    require_once('post/filmes.php');
} elseif ( get_post_type( get_the_ID() ) == 'series' ) {
    require_once('post/series.php');
} elseif ( get_post_type( get_the_ID() ) == 'blog' ) {
    require_once('post/blog.php');
}
?>
    <?php endwhile; else : ?>
    <?php endif; ?>

Would anyone know what the problem is or what I'm doing wrong?

    
asked by anonymous 25.09.2018 / 21:59

1 answer

0

I solved the problem by replacing require_once with include

<?php 
if ( get_post_type( get_the_ID() ) == 'filmes' ) {
    include('post/filmes.php');
} elseif ( get_post_type( get_the_ID() ) == 'series' ) {
    include('post/series.php');
} elseif ( get_post_type( get_the_ID() ) == 'blog' ) {
    include('post/blog.php');
}
?>
    
25.09.2018 / 22:55