Support

Account

Home Forums General Issues Post object with conditions performance, elsif or switch or separate blocks Reply To: Post object with conditions performance, elsif or switch or separate blocks

  • If I needed to use 20+ post object fields in a single page, depending on how often the posts selected would be changed, if this was causing a performance issue, I would find a way to cache the results, for example storing all 20+ results in a single transient that could be loaded using a single db call.

    I honestly don’t know if there is a way to tell if meta values have already been cached. When I’m trying to figure this out I generally install a query monitor plugin and test first with and then without the call to get_post_meta(). If the queries are reduced I leave it in.

    Another thing you might consider is if you’re actually going to use the post data. Will you use the post title, excerpt, content, ect, OR will you only be using custom fields from those posts. If you will not be using standard post field content then you don’t really need the post object and just the ID would be needed to get the custom fields. You can do this by either setting the field to return an array or by get_field('post_object', false, false);