Function get_the_content
doesn’t take post_ID
as param. It has 2 params:
$more_link_text
– (string) (optional) Content for when there is
more text.$stripteaser
– (boolean) (optional) Strip teaser content
before the more text.
So you can’t use it as in your code get_the_content( $p->ID );
– this will get content of current post and use $p->ID
as more link text.
So how to get the content of any post based on post ID?
You can use get_post_field
function:
echo apply_filters( 'the_content', get_post_field( 'post_content', $p->ID ) );