Answer the question
In order to leave comments, you need to log in
How to get content of posts in wordpress?
Hello! There is a plugin for Wordpress that displays a table with a schedule. Now only the title of the posts is displayed there, but I also need to display their description (content). Here is the code itself:
$event = get_posts(array(
'name' => $events_array[$i],
'post_type' => 'events',
'post_status' => 'publish',
'numberposts' => 1
));
$events_array_id[] = $event[0]->ID;
}
$eventin = get_posts(array(
'name' => $events_array[$i],
'post_type' => 'events',
'post_status' => 'publish',
'numberposts' => 1
));
$events_array_id[] = $event[0]->ID;
}
foreach ($eventin as $event) : setup_postdata($event);
the_content(); // returns the content normally
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
endforeach;
Answer the question
In order to leave comments, you need to log in
...
$content =$event->post_content;
$content = apply_filters('the_content', $content);
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question