How to create archive page for taxonomy terms within custom post type

There is an example in the WP Codex which should work for you: Try the following naming convention for your taxonomy term archive template: taxonomy-{taxonomy}-{term}.php So, let’s say you have a CPT named “Projects,” a taxonomy named “Maintenance,” and a term within the taxonomy named “Professional.” Then your naming convention would be: taxonomy-maintenance-professional.php

get_post_type_archive_link(‘post’) returns current category archive

get_post_type_archive_link() doesn’t return a link for the post type post, because technically it has no archive registered on registration of the post type. You can check this, if you inspect the output of get_post_type_object( ‘post’ ). So actually get_post_type_archive_link( ‘post’ ) will return false – see source. You can get the link for the page … Read more

Using a different template per Custom Taxonomies for single term archive pages

I would intercept the template loader at template_redirect: function wpse53892_taxonomy_template_redirect() { // code goes here } add_action( ‘template_redirect’, ‘wpse53892_taxonomy_template_redirect’ ); Then, you would check to see if the query is a custom taxonomy: if ( is_tax() ) { // This query is a custom taxonomy } Next, get the term object, and find out if … Read more

“Sticky” posts for each category (archive.php)

To make this more complete, here is what I have said in comments in reply to the question on hand Just to quickly explain, WP_Query fails catastrophically in some cases where empty arrays are passed to some of its parameters, instead of also returning an empty array as we should expect, WP_Query returns all posts. As for getting the correct stickies, … Read more

How to translate month names in “Archives”

if the translation is only for the archive widget, a filter function might work (to be added to functions.php of the theme): add_filter(‘get_archives_link’, ‘translate_archive_month’); function translate_archive_month($list) { $patterns = array( ‘/January/’, ‘/February/’, ‘/March/’, ‘/April/’, ‘/May/’, ‘/June/’, ‘/July/’, ‘/August/’, ‘/September/’, ‘/October/’, ‘/November/’, ‘/December/’ ); $replacements = array( ‘jan’, ‘feb’, ‘mar’, ‘apr’, ‘may’, ‘jun’, ‘jul’, ‘aug’, ‘sep’, … Read more

Are Custom Taxonomy Templates Possible?

Custom Taxonomy templates are entirely possible, the order of the template loading is, taxonomy-{sometax}-{someterm}.php – If the taxonomy were sometax, and taxonomy’s slug were someterm taxonomy-{sometax}.php – If the taxonomy were sometax. taxonomy.php archive.php index.php This template hierarchy give you tons of control on how you want to alter the display of taxonomies as a … Read more

how do I get the date in a date archive page

Use get_query_var() to get the date parts: $year = get_query_var(‘year’); $monthnum = get_query_var(‘monthnum’); $day = get_query_var(‘day’); In wp_title() a call to get_query_var(‘m’) is used for the month too, but I got always just a 0 as value even on an URL like /2008/09/05/. If you want to print the month name, use: $GLOBALS[‘wp_locale’]->get_month($monthnum); The month … Read more

Filter blog archive by category in URL

Even if default posts are stored in same table but they have different behavior and different characteristics. CPT has post type archive but default post type archived is called as blog and the taxonomy filter is called as tag/category archive. You can access the category/tag archive using For categories: /?cat={category_id} //e.g. ?/cat=5 For tags: /?tag={tag_slug} … Read more

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