0
votes

Something is wrong with one post

Info about post:

ID: 8619

post_author: 1

post_date: 2014-02-28 15:56:08.000000

post_date_gmt: 2014-02-28 13:56:08.000000

post_title: 2014 02 28

post_status: publish

ping_status: open

post_name: 2014-02-28-2

guid: http://example.lt/?post_type=newsletter&p=8619

Query:

$args = array (
    'p'=> 8619,
);

$query = new WP_Query( $args );


if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
        var_dump(get_the_content());
    }
} else {

}

wp_reset_postdata();

And I'm not getting post, something if wrong with post data, because if I change id to any existing post all is ok.

2
make sure that there is a post with id = 8619 and post_type=newsletter - Pratik
Yes I copy this data from db. - Wizard

2 Answers

2
votes

Try this as @Pratik said. You need to pass the key 'post_type' => 'newsletter'. As default it targets 'post_type' => 'post'

$args = array (
    'p'=> 8619,
    'post_type' => 'newsletter'
);

$query = new WP_Query( $args );
1
votes

Try This by this you can get single post

<?php
$post_id = 8619;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo $title;
echo $queried_post->post_content;
?>