[wp-trac] [WordPress Trac] #60852: Block Templates: Make conditional tags work when processing content for REST API

WordPress Trac noreply at wordpress.org
Tue Apr 9 15:39:00 UTC 2024


#60852: Block Templates: Make conditional tags work when processing content for
REST API
-----------------------------+-----------------------------
 Reporter:  Bernhard Reiter  |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Future Release
Component:  General          |     Version:
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:
-----------------------------+-----------------------------

Comment (by Bernhard Reiter):

 I gave this some more thought, and I'm not sure it's possible to implement
 this in a way that's compatible with the Site Editor.

 I think there's a problem with using a conditional template tag (e.g.
 `is_single( 'my-post' )` to check that the post with slug `my-post` is
 currently rendered) in a template that's less granular than that template
 tag (e.g. the Single Posts template).

 Other -- more hypothetical -- examples could include a `is_tag()` (to
 check for a Tag Archives page), when used in a generic Archives template
 (which AFAICT the Site Editor doesn't currently support -- but might
 eventually). Refer to the [https://developer.wordpress.org/themes/basics
 /template-hierarchy/#visual-overview Template Hierarchy] for other
 possible scenarios.

 The problem is that we have only have insufficient context available when
 editing a template in the Site Editor that (potentially) includes hooked
 blocks with more fine-grained criteria; as a consequence, we can't know
 whether or not to show a hooked block that's e.g. only injected into a
 single post with `my-post` as its slug, when we're currently editing the
 generic Single Posts template (which applies to ''all'' single posts,
 regardless of their slug).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60852#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list