Tag Info

New answers tagged

1

You could use in_array() with get_queried_object_id(): if( is_category() && in_array( get_queried_object_id(), $archive_categories ) ){ echo 'stuff'; } else { theme_loop(); }


0

A canonical redirect: The GET parameter m can trigger a canonical redirect when permalinks are used. The canonical redirects are activated with the following hook: add_action('template_redirect', 'redirect_canonical'); where redirect_canonical() is a rather complicated function. Here's the skeleton of the part that's active within this "monster" ...


1

Don't create a new query and loop just to alter posts per page. Add a function hooked to pre_get_posts and alter whatever parameters you want in there before the query is run. This would go in your theme's functions.php file, or a plugin. function wpd_testimonials_query( $query ){ if( ! is_admin() && $query->is_post_type_archive( ...


0

Use wp_get_object_terms function to get any taxonomy you want, category, tag, state, etc. For example: $terms = wp_get_object_terms(get_the_ID(), 'state'); $state = array_pop($terms); echo $state->name; This function is returning array of terms, so in case you only have one state, it will return array of one item in it.


0

You can use the_terms function in WP to display your term values in your archive page. Usage the_terms( $id, $taxonomy, $before, $sep, $after ); Parameters $id (int|req) -> Post ID. Default: None $taxonomy (str|req) -> Taxonomy name. Default: None $before (str|opt) -> Text to display before tags are displayed. Default: Empty string $sep (str|opt) -> ...


0

You can use a filter pre_get_posts() to modify SQL query WHERE part: add_filter( 'posts_where', function ( $where ) { $where = preg_replace("regex pattern", "", $where); return $where; }, 10, 2 ); It is a bit hacking solution but should work.


1

Your problem is your naming convention. Look at the Template Hierarchy. The archive- prefix is reserved for date and custom post type archive pages. You are using this as prefix to a page template This is not only confusing to humans, but to Wordpress as well. For page templates you should be using the page- prefix. Just a note, as from version 3.4 you ...



Top 50 recent answers are included