• Resolved Oliver Campion

    (@domainsupport)


    Hi all,

    So in re-building this town site with Twenty Twenty-Two we’ve managed to do so entirely without a child theme. I don’t like child themes because they quickly become out-of-sync with the parent theme which can causes minor inconveniences to quite drastic problems. Child themes also have quite an impact on load times.

    In order to get around the problem of how to display blocks and content programatically without having theme files to edit, we’ve created this content by building custom plugins that produce shortcodes that can be used with the Shortcode Block. Great.

    However, quite a lot of this is pretty basic conditional stuff like …

    Does the current page / post have a featured image? If so show the featured image, if not show another default image.

    We’ve tried to find a plugin that would allow for conditional content like this by adding a “Conditional Content” block but can only find plugins that conditionally hide or display the relevant blocks with CSS, not one that shows them programatically.

    Am I missing something or do I need to develop a plugin to do this? ??

    Oliver

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi @domainsupport – I just did a simple test via @ndiego’s “Block Visibility — Conditional Visibility Control for the Block Editor” plugin:

    https://www.ads-software.com/plugins/block-visibility/

    – Went to Appearance > Editor > Page template
    – Toggled off the visibility on the Post Title block

    Editor beta Self hosted Test WordPress

    I then spot-checked several pages on the front end, and I don’t see the Post Title block output anywhere in the code, so it doesn’t look like CSS is being used to hide it. I did another test with a different type of block and got the same result. I didn’t test anything complex, but you might want to have a look and see if it might work for your needs.

    Thread Starter Oliver Campion

    (@domainsupport)

    Thanks Kathryn,

    I’m not sure how I missed that plugin … however, I’m not seeing how to conditionally show content using it on whether a post has a featured image or not.

    There is a _thumbnail_id meta key which is present if a post has a featured image … but it looks like testing for metadata is a premium feature of that plugin …

    Here’s a look at what’s currently included with Pro:

    • Support for all post and user metadata (custom fields).

      Oliver

      Moderator Kathryn Presner

      (@zoonini)

      I didn’t dive into looking at that specific example you mentioned with the featured image, as it seemed like it was just one example of something you’re trying to do.

      The best person to help guide you is probably Nick, so I’d suggest you post in the plugin’s forum to see if he can tell you whether his plugin would allow you to do that specific thing, or if not, if he knows of another plugin that might already exist to help you achieve it.

      Thread Starter Oliver Campion

      (@domainsupport)

      Good plan.

      Will do, thanks!

      Oliver

      Moderator Kathryn Presner

      (@zoonini)

      You’re very welcome!

    Viewing 5 replies - 1 through 5 (of 5 total)
    • The topic ‘Conditional Content Block’ is closed to new replies.