Support

Account

Forum Replies Created

  • This reply has been marked as private.
  • Thank you Elliot for your precious tips!

  • And if I try to reduce the array to one element only, I get an error and, at the bottom I don’t get the right related post but another one, outside the original related group.


    $posts = get_field('related_content');
    $random_post = array();
    array_push($random_post,$posts[array_rand($posts)]);
    if( $random_post ):
    setup_postdata($random_post);
    the_title();
    endif;

    returns a bunch of:

    Notice: Trying to get property of non-object in /Users/totanus/Sites/ovestsesia/wordpress/wp-includes/query.php on line...

    And then prints an incorrect the_title();

    I’m missing something, of course…

    Teo

  • Thank you Elliot!
    Actually I tried that before opening this topic. When I try to access and echo a random page by declaring its index I get:

    Catchable fatal error: Object of class WP_Post could not be converted to string in...

    As you may guess I’m more a front-end guy than a php one…

Viewing 4 posts - 1 through 4 (of 4 total)

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.