Trending Now 1.1.7
Some themes will not render a shortcode on the homepage. The workaround is to put the widget in a widget area instead — but a widget area is site-wide, so the block meant for the homepage then appears on every page. Nothing in the plugin could say render here, not there.
Added
-
match_pathon the shortcode,matchPathon the block. A comma-separated list of paths. Empty or absent renders everywhere, so nothing existing changes.[trending_now match_path="/,/trending"]Matching is exact and trailing-slash-insensitive:
/trendingcovers/trendingand/trending/, but not/trending/page/2/and not/trending-2024. That was chosen over prefix matching deliberately — a rule where/archivesilently swallows forty child URLs is harder to reason about than one where you add a second entry. If a section-wide rule is wanted later, a trailing*is the additive way in.Query strings are ignored, so
/?utm_source=xstill matches/. On a subdirectory install/means the site's homepage rather than the server root. A pasted full URL works — the scheme and host are stripped. Curated links are unaffected; this gates a placement, not an item.Both
match_pathandmatchPathwork on the shortcode.shortcode_parse_atts()lowercases attribute names while parsing the tag, beforeshortcode_atts()merges them against defaults, so a single-spelling attribute would have made the documented camelCase form a silent no-op the moment anyone typed a capital P. The block takesmatchPathonly — block attributes are not lowercased.The gate runs before the renderer. A non-matching placement adds no render-cache variant, and a matching one shares the variant it would have had without the attribute.
The block still previews in the editor regardless of the path, since it renders over REST with the editor's own URL. That bypass requires an edit capability, so an anonymous REST or admin-ajax read of rendered content is gated like any other request rather than exempted.
This does not change the theme restriction that pushed you into a widget. A theme that strips shortcodes from the homepage still will. What it fixes is the workaround leaking onto every other page.