the_content is displaying nothing for a costum pos

2019-08-07 05:58发布

When I was using the default post type in Wordpress, the code above was working well. But with custom post types, It is displaying nothing.

   <?php
    $p=$_GET['p'];

    header('Content-Type: text/html; charset: UTF-8');
    require( '../../../../wp-load.php' );

    $my_query = new WP_Query();
    $my_query->query(array( 'post__in' => array($p)));

    if ($my_query->have_posts()) : while ($my_query->have_posts()) : $my_query->the_post(); 

    echo the_content();


    endwhile;
    endif;
    ?>

Your help is highly appreciated

1条回答
冷血范
2楼-- · 2019-08-07 06:55

Custom post types are not posts.

So the solution is:

$my_query->query(array('post_type' => 'aya-bi-aya', 'post__in' => array($p)));

Looking hours for solution, and finding it minutes after posting question on SO

查看更多
登录 后发表回答