Listing pages which uses specific template [duplicate]

You can do this with a WP_Query meta_query. The page template filename is stored in post meta under the key _wp_page_template: $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘_wp_page_template’, ‘value’ => ‘product.php’ ) ) ); $the_pages = new WP_Query( $args ); if( $the_pages->have_posts() ){ while( $the_pages->have_posts() ){ … Read more

Prevent comments_template() to load comments.php

Not sure the following solution is better than the solution in OP, let’s just say is an alternative, probably more hackish, solution. I think you can use a PHP exception to stop WordPress execution when ‘comments_template’ filter is applied. You can use a custom exception class as a DTO to carry the template. This is … Read more

How do you access the Product Short Description in a WooCommerce email template? [closed]

I finally tried using var_dump() on $item and $_product, which are both used in the email-order-items.php template. $_product revealed a post object, which itself has a post_excerpt property, which looks like it holds the contents of the “Product Short Description” from the WooCommerce product form. So, to add the description beneath the item name, I … Read more

What’s the purpose of the paged.php file?

If we look in template-loader.php, we can see the conditions under which paged.php will be loaded: if ( defined(‘WP_USE_THEMES’) && WP_USE_THEMES ) : $template = false; if ( is_404() && $template = get_404_template() ) : elseif ( is_search() && $template = get_search_template() ) : elseif ( is_tax() && $template = get_taxonomy_template() ) : elseif ( … Read more

How can I load a page template from a plugin?

You can use the theme_page_templates filter to add templates to the dropdown list of page templates like this: function wpse255804_add_page_template ($templates) { $templates[‘my-custom-template.php’] = ‘My Template’; return $templates; } add_filter (‘theme_page_templates’, ‘wpse255804_add_page_template’); Now WP will be searching for my-custom-template.php in the theme directory, so you will have to redirect that to your plugin directory by … Read more

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