Skip to main content

Timeline for Find Any Theme's page.php File

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Nov 4, 2022 at 23:54 vote accept Rick Hellewell
Oct 20, 2022 at 20:15 comment added Jacob Peattie You can use has_shortcode() on the current page's content to do that.
Oct 20, 2022 at 18:36 comment added Rick Hellewell Sorry for a misunderstanding. If the shortcode is in the content, then I need to use wp_head/wp_footer actions to add additional code to the page when displayed, using any template. So if there is a way to 'sense' a shortcode before the page is output, that would be used instead of a custom template.
Oct 19, 2022 at 18:59 comment added Jacob Peattie This just seems like a really problematic approach. Shortcodes typically go in post content so why are you using a shortcode in a template? And how are you determining where to put the shortcode? If you're just looking for the_content() then why not just filter that instead of copying the template?
Oct 19, 2022 at 18:04 comment added Rick Hellewell @JacobPeattie The new template will be stored in the plugin's folder, and inserted via the template_include filter. So will survive a theme update. The new template will have a shortcode. I'm not sure if there is a way to 'sense' a shortcode and then use the wp_head/wp_footer add_action to insert additional code if the shortcode is in the page's content. That might be another question, though. (The shortcode requires additional code to function properly.)
Oct 19, 2022 at 8:00 comment added Jacob Peattie Also, if you're copying the theme's template that copy will be deleted whenever the theme is updated.
Oct 19, 2022 at 8:00 comment added Jacob Peattie If you're using a shortcode I don't understand why you need to copy the theme's template? If you need functions to handle a form submission then those don't belong in the template and you should handle it with action callbacks.
Oct 19, 2022 at 1:27 answer added Rick Hellewell timeline score: 0
Oct 19, 2022 at 0:18 history asked Rick Hellewell CC BY-SA 4.0