Posts

Showing posts with the label posts

Wordpress php get_post_meta for post template

Wordpress php get_post_meta for post template I am using this little technique outlined here : https://mekshq.com/include-javascriptonly-on-specific-wordpress-page-templates/ to limit the quantity of scripts etc. which load up on different pages on my site, by using the code: $template_name = get_post_meta( $wp_query->post->ID, '_wp_page_template', true ); if($template_name == 'my-custom-template.php'){ //load my scripts } But I would like to use the same technique for POST templates, however '_wp_page_template' doesn't seem to recognize post templates, just page templates. Is there some way I can change this to query if it is a post template instead? If not can I at least query if it is a post rather than a page, irrespective of template? That would probably be good enough, although querying the template would be preferable as it would give me more flexibility going forward. I tried to look it up but sry, I am really not very strong in .php and mo...