Articles of template include

WP overwrites my setup_postdata() setup

I’m trying to display under a (very) custom URL a post in a template of my choice. My post’s ID in this example is 1008 and my template name ‘/singles/lecture.php’. Im the future will check the URL and add a condition when to do the action – now for tests the condition is just if […]

unexpected T_FUNCTION in plugin template

I have a plugin I have developed for a client which works fun on my server but doesn’t work on theirs, they are on godaddy so I am guessing it’s an issue with their PHP version? add_filter(‘template_include’, function ( $template ) { if(is_tax(‘hha_cats’)){ $template = dirname( __FILE__ ) . ‘/templates/category-hhavideo.php’; } if( is_post_type_archive( ‘hhavideo’ ) […]

Template Include crashing browser

I am creating a plugin which requires use of custom templates so using the following code to use the templates: add_filter(‘template_include’, ‘hhavideo_set_template’); function hhavideo_set_template( $template ){ if(is_archive(‘hhavideo’) && ‘archive-hhavideo.php’ != $template ){ $template = include( plugin_dir_path( __FILE__ ) . ‘templates/archive-hhavideo.php’); } if(is_singular(‘hhavideo’) && ‘single-hhavideo.php’ != $template ){ $template = include( plugin_dir_path( __FILE__ ) . ‘templates/single-hhavideo.php’); […]

template_include filter does not render the custom template

I created a plugin that will render a shortcode that is entered to a page. This Shortcode shall override the theme’s page template and use the one that I included on the plugin Here’s my code: api.php class Api{ public static $logger = null; function Api() { add_shortcode(‘my_shortcode’, array(&$this, ‘my_shortcode_function’)); } function my_shortcode_function($atts,$content = null) […]

problem including page template

I am creating a one page wordpress site. The code I am using does work but for some reason it will not include page templates. It only gets the content from the page editor but will not get the custom html that is inside the page template so I am trying to include the file. […]

A include_template Question

Right now I am building virtual pages on a wordpress install. I use the include_template hook to add some logic that checks for a 404 page & some regex to look for a specific pattern. This seems horribly inefficient. If my plugin is doing this, and other plugins are doing this, arn’t we all just […]

Content vs Template on custom post

I just wrote a custom post (suppliers) as a plugin (with meta content) that works great. I’ve also created a template page (single-suppliers.php) within the same plugin to display the data. I wrote it in such a way that, if someone so desires, they can create their own single-suppliers.php page in their template and get […]

How to check if txt file exists inside template folder?

I have a folder inside my theme where I hold some txt files which I am including in a theme. The problem is that before including txt file I need to check if it does exist. I fail checking it the following way and have no idea why it wont work, always returns false. $themeLocation […]

Link to file in plugin directory from wordpress template?

I know that plugins and theme files should be kept separate but for for internal use I need to do it this way. In my themes header.php file I want to include a php file which just contains html, from my plugin directory. The path is basically /wp-content/plugins/my_plugin/my-html.php I can’t seem to figure out the […]

WordPress rewrite rules for state and city

I’m building a site where every state and city in the US has a landing page. I have a database of every city, state, and zip code, set up as a custom post type in WP. Here’s what I’ve done successfully to create a landing page for every state: function em_rewrite_rules($rules) { $newrules = array(); […]