Executing Queries in tag.php

That’s because the main query is being discarded and replaced with your custom query. You’ve not told your custom query to look for that tag, so why would it? You might also notice your pagination is broken for the same reason, you’ve not told the new query which page you’re on, so why would it … Read more

Get page by template?

The page template’s filename is stored as a post meta with key ‘_wp_page_template’, so basically you can use get_post_meta($post_id, ‘_wp_page_template’, true); to get the template filename for the page with ID $post_id. You can also do the reverse (i.e. getting id from page template filename) using Custom Field Parameters in WP_Query or other wordpress functions. … Read more

How to display a listing template of a certain taxonomy?

What you want to do is impossible without a page.php type of template. There is no template hierarchy that support what you want to achieve. It works exactly the same with categories. taxonomy-categorycourses.php will not display a list of categorycourses, so would category-categorycourses.php if categorycourses was a normal category. If you click on categorycourses, you … Read more

Templates for Custom Post Types and Custom Taxonomies

You have totally missed the naming convention when coming to the taxonomy archive pages, and most probably the same goes for your archive pages for your custom post types Here is how your taxonomy archive pages should look like taxonomy-{taxonomy}-{term}.php – If the taxonomy were sometax, and taxonomy’s term were someterm WordPress would look for … Read more

Check if a menu is empty?

wp_nav_menu has the argument fallback_cb, which is the function called if a menu doesn’t exist. This is set to wp_page_menu by default, which is why you see a list of pages if the menu doesn’t exist. If you explicitly set that to false, then nothing will be output if the menu doesn’t exist. EDIT- Given … Read more

$wp_query initiation?

User Rarst has a very famous answer where he lays out the load process. Looking at this graph whenever wp-blog-header.php gets loaded it calls function wp() which sets up many of WordPress globals like $post and $wp_query. ( Secondary Reference by User Gmazzap ) That’s the technical side of things but it looks like the … Read more

WooCommerce – Load Templates From Plugin For All Template Files

WooCommerce uses the template_include filter/hook to load main templates like archive-product.php and single-product.php. And here’s the class which handles main templates. And there’s a filter in that class which you can use to capture the default file (name) which WooCommerce loads based on the current request/page — e.g. single-product.php for single product pages. You can’t, … Read more

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