Query post for ‘selected category’ in archive.php

The easiest way to do this is to simply make a category.php template file, that way you’re not jamming everything into one template with multiple query’s and conditionals. http://codex.wordpress.org/Template_Hierarchy#Category_display It is unclear what you mean by “featured”, do you want an url like http://example.com/portfoliography/architecture to have a select posts at the top? Or do you … Read more

force category base – archive pages work WITH & WITHOUT category base slug in url?

I found a solution here: 404 on category.php pagination So, to fix my issue I just needed to add these custom rewrite rules to functions.php: add_action( ‘init’, ‘wpa58471_category_base’ ); function wpa58471_category_base() { add_rewrite_rule( ‘blog/([^/]+)/page/(\d+)/?$’, ‘index.php?category_name=$matches[1]&paged=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘blog/([^/]+)/(feed|rdf|rss|rss2|atom)/?$’, ‘index.php?category_name=$matches[1]&feed=$matches[2]’, ‘top’ ); } Now, all blog pages work, including main blog page, archives, categories, and … Read more

Current category link filter

Internally wp_list_categories() uses get_term_link() for the URL of the terms. That function can be filtered using the term_link filter, so you could filter any links to the current term and replace them with links to the post type archive: function wpse_307202_term_link( $termlink, $term, $taxonomy ) { if ( is_tax( ‘cat_projet’ ) ) { if ( … Read more

How to get category URL with the slug?

The WP function get_category_link() will do the trick. /** * Gets the URL for a category term archive based on the category’s slug. * * @param string $category_slug The slug of the category to get the category arcive for. * * @return string The category (term) archive URL. Empty string on error. */ function wpse_get_category_url_by_slug( … Read more