Get template part vs locate template function

First of all note that get_template_part internally uses locate_template, so your feeling that the latter is slower is wrong. If you look at the code, get_template_part is little more than a wrapper for locate_template, so if one work and the other not, there are 2 possibilities: you are using get_template_part wrong there’s some hook on … Read more

How can I see what template parts are being called for rendering the viewable page?

You can view the template part by using get_template_part($slug) It’s one of those hidden gems inside of WordPress that don’t get the attention they deserve. The get_template_part function is essentially a PHP include or require, on steroids: It already knows where your theme is located and it will look for the requested file in that … Read more

Limit number of pages that use a specific template?

You can approach this by first using a database query to count the number of pages that are already using the template: $query = “SELECT COUNT(*) as total FROM prefix_posts as p JOIN prefix_postmeta as m ON p.ID = m.post_id WHERE p.’post_type’ = ‘page’ AND p.’post_status’ = ‘publish’ AND m.’meta_key’ = ‘_wp_page_template’ AND m.’meta_value’ = … Read more

Template files missing after moving site

Sounds like it could be an issue with the database and serialization of the plugin options. I’ve had problems before with plugin settings etc when moving a site using the xml export. The category templates plugin writes a lot of options to the db and they could be corrupted. As a test try creating a … Read more

Retrieve the template directory URI via global or get_template_directory_uri() every time?

I would stay stick to the function. PHP caches functions for speed and efficiency. In some situations, using a function is faster then using a variable. There are other benefits too – imagine if you changed the name of your variable – you would have to go and update every piece of code where it’s … Read more

How to create tag.php

Unfortunately all of your code is wrong. What you are doing is the same as query_posts, which should never be used. Also, never swap the main query on any type of archive page or on the home page for a custom query To create a tag page, just simply make a copy of your index.php, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)