The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End posts and pages In WordPress home

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #42414

    I am using a function in functions.php to get posts and pages displayed on the homepage.

    add_filter( 'pre_get_posts', 'my_get_posts' );
    function my_get_posts( $query ) {
    if ( is_home()) {
    $query->set( 'post_type', array( 'post', 'page') );
    $query = apply_filters( 'the_content', $query);
    return $query;

    I noticed that by doing this, the page does not render shortcodes and ignores the fact that a page template is assigned to the page. So I tried using passing the return $query through a filter like so

    $query = apply_filters( ‘the_content’, $query);

    but then I get this error Object of class WP_Query could not be converted to string

    I don’t know any way around it. Do you?


    It’s because you’re trying to return an object. You have to use references.


    return $query->reference;

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.