Permalink remain the same on each page

Firstly, you should never use query_posts to construct custom queries. This is not just my emphasis, but the codex as well. The one big problem with query_posts is, it many circumstances, pagination fails Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to … Read more

Problem dynamically generating an all purpose title tag

I wound up fixing it like this. All pages now work. But it looks …well …ugly. <?php if (function_exists(‘is_tag’) && is_tag()) { single_tag_title(‘Tag Archive for &quot;’); echo ‘&quot; | ‘; } elseif (is_archive()) { wp_title(”); echo ‘ Archive | ‘; } elseif (is_search()) { echo ‘Search for &quot;’.esc_html($s).’&quot; | ‘; } elseif (!(is_404()) && is_single() … Read more

get_the_post_thumbnail() – Invalid argument supplied for foreach() in /wp-includes/post-thumbnail-template.php on line 64

This Trac ticket here describes your problem and the cause: https://core.trac.wordpress.org/ticket/26321 I got a warning/error related to update_post_thumbnail_cache() function: Warning: Invalid argument supplied for foreach() in ./wp-includes/post-thumbnail-template.php on line 64 The $wp_query->posts array is missing, but we have the single $wp_query->post. foreach ( $wp_query->posts as $post ) { if ( $id = get_post_thumbnail_id( $post->ID ) … Read more

Custom Post Type – Permalink Problem

Thanks to Anjum for his suggestion in the comments. The problem has been solved by removing the front-slash in the rewrite slug. The error was caused by: ‘rewrite’ => array ( ‘slug’ => ‘movies/’, ‘with_front’=> false ), The error has been solved by the following modification: ‘rewrite’ => array ( ‘slug’ => ‘movies’, ‘with_front’=> false … Read more

How to make a template for a specific post of a custom post type?

As Pages are a special built in Posttype, they get an own template hierarchy. Other “normal” post types and custom post types can only be templated by “single-$posttype.php”. You can however hook into the single_template filter and make wordpress redirect to your template file: function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == ‘account’) { $located … Read more

WP_Query wooCommerce category

You can try the following code to check whether a category with a name exist of not $search_category_name=”T-shirts”; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms(‘product_cat’, array(‘orderby’ => ‘slug’, ‘hide_empty’ => false)); foreach ($parent_terms as $pterm) { //check whether the category_name exists if ($search_category_name == $pterm->name) … Read more

How to show only the date, the title and a little “summary” of my WordPress post in my custom theme?

The get_template_part(‘content’, get_post_format()); line includes content from one of the other files in your theme based on the post type, the file name will be something like content-page.php (or content.php if the format is not found). If you print out what get_post_format() returns, you will be able to tell which content file to look into. … Read more