Home Forums Front-end Issues True – false Reply To: True – false

  • @redeclipse

    It seems to look good in terms of no missing/extra brackets/commas, but I do see one potential issue.

    First, I can only assume $current has the appropriate data. During testing, you can leave one element out at a time… or hard code otherwise dynamic values.

    But.. the issue I see…

    When I was building my query… I looked at the existing ACF examples and docs and when using (as suggested):

      'key' => 'show_main',
      'compare' => '==',
      'value' => '1'

    .. it didn’t work for me.

    But when I changed it to what made more sense to my brain anyway… which was:

      'key' => 'show_main',
      'compare' => '=',
      'value' => TRUE

    … then it worked!

    That quick change might do it for you. I am not sure if double equals matters… I didn’t see double equals in the WP docs so I used single (which is the default). Note: I do not wrap TRUE in quotes in my example.

    Also, my bad on steering you towards get_posts() – it seems to be just a matter of preference in most cases.

    I noticed that in your original post you were using get_page() (singular) and I hadn’t heard of it, so I looked it up and saw that it had been deprecated in favour of, as it turns out: get_post() (singular)

    Now… I know you can achieve near same results with get_pages() and get_posts() (both plural)… maybe, just maybe, get_pages() is more appropriate for you. I only say that because Pages are hierarchical by nature, and maybe that fact is important to you and your query. I don’t know… but… with that said… with get_page() falling away, perhaps get_pages() will as well. Time will tell.

    At any rate, if you decide to jump over to get_pages() you just have to modify your args slightly.

    Best of luck with your project!