wp_enqueue_scripts doesn’t work for template pages
wp_enqueue_scripts doesn’t work for template pages
wp_enqueue_scripts doesn’t work for template pages
You are probably confused by the output of array_values() which will always get you only array values without keys while $atts variable is actually an associative array. To extract your attribute use $arr = $atts[‘tablepageid’]; Cheers
Templates might load faster because they don’t have to do a database query, they have already all the text hardcoded in them. Also, this might not be the right way to do it and you might have problems or conflicts if you are not doing it right. Considering the fact that the speed diference will … Read more
Seems like I just need to set has_archive to a string instead of true with the desired slug, in my case archive/dogs. Then, create a page with the dogs slug and set the desired template to it.
Sending Messages Back to the Template After Processing?
This is not possible at all. There aren’t even duplication between page templates between the bundled themes. There is no way for you to know or to predict functions, outlay or markup in any template. IMHO, because of this, templates should always reside within a theme and not in a plugin. Afterall, templates are theme … Read more
It is normal to have some text used in template. Typically that would be pieces of “technical” text, related to interface and which must be in code to be localized. In solutions meant for public use it is certainly not normal practice to have actual content hardcoded in templates. For private projects it is more … Read more
I think you’re misunderstanding the function get_page_template_slug When you call $template = get_page_template_slug( $post_id ); it won’t return index.php if you are using the default theme template. It only works when viewing Pages and will either return the slug of the Custom Page Template assigned to that Page or an empty string otherwise. So if … Read more
If you’re using that template for only one page, you can try this function: /** * @param string $template Base name of the template. */ function wpse_233924_get_page_link($template) { $query = new \WP_Query; // Get page which is using the $template. $page = $query->query([ ‘post_type’ => ‘page’, ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => $template, ‘no_found_rows’ => 1, … Read more
Instead of: is_page(‘contact-template.php’) Try: is_page(‘contact’) is_page expects a post ID or slug. If instead you want to enqueue this CSS for any page using this template, put the enqueueing PHP into the template itself.