Try this:
add_action( 'template_redirect', 'my_test_if_archive' );
function my_test_if_archive() {
global $wp_query;
$qv = array_keys( $wp_query->query );
$archives = array('year', 'monthnum', 'day', 'w', 'm', 'author', 'post_type');
$is_archive = ! empty( array_intersect( $qv, $archives ) );
$is_tax = ! empty( $wp_query->tax_query->queries );
if ( $is_archive || $is_tax ) {
// this is an archive
}
}
Related Posts:
- Target a page with query
- Conditional Tag Custom Querys?
- Get all image from single page using this query
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- Add multiple value to a query variable in WordPress
- Compare two numeric custom fields
- wp_dropdown_categories with multiple select
- How to tune search argument in WP_Query to show only exactly the same results?
- Custom query filter not working on woocommerce category page
- How to delete a transient on post/page publish?
- How to get my loop to pull posts into three columns
- Custom $wpdb Query for Custom Post Type by Category
- Can’t pass table to $wpdb->prepare
- How to extract all ID variables from a query string?
- WordPress creating excessive joins on meta_query with search
- How to display liked posts of current user in wordpress?
- How to tell if $query_var isset?
- Sorting Grids with Essential Grid and Events Manger
- Remove Unnecessary Mysql Query
- Get the timout value of a saved transient?
- Grouping related postmeta data via SQL query
- Does meta_query work within get_posts array?
- How to remove duplicate query on page load or make them cacheable
- Slow meta_query with about 4 milion record on wp_postmeta
- How to show more than 5 posts?
- wpdb::prepare() isn’t working
- How can I apply a meta query for a single custom post type in the main query?
- mySQL query. ORDER BY meta_key
- Huge amount of queries on my site
- Strange string in console from wpdb query
- Using pre_get_posts to target a query in the sidebar
- Update slug (URL) of pending posts via phpMyAdmin
- What’s wrong with my $wpdb prepare?
- How do I use get_query_var() within plguin code
- How to display related posts by same publish date?
- Get post according to current taxonomy
- Exclude featured image and custom field from this get_attachment query
- Ordering by a metadata subfield in WordPress?
- Alter query with posts_clauses to retrieve NULL values last
- Query based on title, with ‘compare’ => ‘IN’
- Issue with using add_rewrite_rule() for post querying custom fields
- Plugin will sort users by usermeta
- Exclude all sticky posts front page twenty twelve
- Query posts according to specific post meta values
- Check if CTP category taxonomy is set in shortcode
- empty query breaks other queries
- Problem in exploding the_content to array
- Custom SQL Query passing array to WHERE p.id
- What is wrong with my wp query, cant exclude the category that i want
- how to insert missing tags into the posts through mySQL?
- Query posts dynamic date range
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- Get previous posts list
- how to replace old DW site with new WP site? [closed]
- Mysql query not working on WordPress 4.2.2
- WordPress SQL query to tag all posts containing a specific word on title
- get_post_meta with WP_query
- Order terms by count – missing terms
- Querying Advanced Custom Fields
- How to rearrange a pool of posts joined using two queries?
- wpdb update multiple row?
- How properly create a blog template for wordpress?
- Can I include get_posts in this array?
- Is there a way to add a link directly into this media query?
- Custom query Custom-Post-Types creates error
- Formatting a date/time returned from a custom $wpdb query
- Problem on displaying the results on my query
- Rewrite rule for query params
- Improve performance of slow query
- WordPress search in modified post title
- meta_query not working
- Hook into the Admin Dashboard and redirect users
- WordPress query: merge meta key (number) values and sort
- Displaying data from custom table
- SEO friendly query vars
- Question about of query
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- Modify behaviour of “s” parameter in wp_query
- OR condition not working
- Query not returning child posts for any parent post ID
- How to make MySQL search queries with quotes
- Use $wpdb->get_results with filter based on array
- Add Hook for clearing transient when post is added
- Displaying popular posts
- Find all posts via SQL beginning with A of type B
- Show links to child pages on both parent AND child pages
- learn to run wpdb class
- Display old posts if no future posts exist
- Modify Global Posts Plugin
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- How to add multiple values with add_query_arg?
- How do I troubleshoot Maximum execution time of 60 seconds exceeded in updating a Media File?
- update $wpdb one query
- Admin Post List table Query filtering “WHERE” for custom post type
- Prevent executing query for wp_global_styles
- How to use a dynamic term id for the query block