• Resolved pagecrawler

    (@pagecrawler)


    How do I display a widget on custom post pages where the value of a custom field dictates whether to display or not:

    $customfield= get_post_meta( $post->ID, ‘_unavailable’, true );

    if ($customfield === ‘yes’);

    The above results in the widget not displaying at all.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Mej de Castro

    (@mej)

    Hi @pagecrawler,

    Thanks for reaching out to our support threads. Could you please try using either of these codes?

    get_post_meta( $post->ID, ‘_unavailable’, true ) === ‘yes’

    get_post_meta( get_the_ID(), ‘_unavailable’, true ) === ‘yes’

    Thanks and please let us know if this works for you.

    Regards,
    Mej, from the Widget Options Team

    Thread Starter pagecrawler

    (@pagecrawler)

    Thank you for your support.

    Unfortunately the above code does not work. The widget does not appear on the front end when either of the codes are used, even when reversing the statement eg:

    get_post_meta( $post->ID, ‘_unavailable’, true ) !=== ‘yes’

    Plugin Author Mej de Castro

    (@mej)

    Hi @pagecrawler,

    It is working on our end. But I understand we might have different set up. We will look further into this.

    Kind Regards,
    Mej, from the Widget Options Team

    Plugin Author Mej de Castro

    (@mej)

    Hello @pagecrawler

    I have reviewed the code snippet:

    get_post_meta( get_the_ID(), '_unavailable', true ) === 'yes'

    It is working correctly on my end.

    Could you please confirm if the value saved in get_post_meta( get_the_ID(), '_unavailable', true ) is actually 'yes'? I ask because there is a possibility that the saved value might be the boolean true instead of the string 'yes'.

    Thank you,
    Mej, from the Widget Options Team

    Plugin Author Mej de Castro

    (@mej)

    Hi @pagecrawler,

    I hope you are doing well. Have you managed to display a widget on your custom post pages using the cod snippet?

    Thanks and we are waiting for your reponse.

    Kind Regards,
    Mej, from the Widget Options Team

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.