You’re almost there my friend. Just check with $query->is_tag()
rather than only is_tag()
. So your updated code will be-
function main_query_mods( $query ) {
// check http://codex.wordpress.org/Conditional_Tags to play with other queries
if(!$query->is_main_query()) {
return;
}
if($query->is_tag()) {
$query->set('posts_per_page',10);
}
}
add_action( 'pre_get_posts', 'main_query_mods' );
Related Posts:
- Using get_terms for custom taxonomy in functions.php
- Remove tag on my RSS Feed
- get_the_excerpt() not returning anything when post has no excerpt
- Automatically add author’s name to post_tag
- Adding a class to tag list in a function
- How to preserve edits to Name or Slug of term when using wp_update_term on save?
- Create single.php for specific tag by tag id or name
- list tags with count in author profile page
- Product Tags in Add New product as checkbox list [closed]
- Retrieve tags data in post body
- Echo tags used to describe the theme
- Frontend tag edit/submit form
- Is possible add icon in title posts only in specific tag?
- Custom taxonomy widget in admin area
- Display tags that only appear in one category
- Add a unique class to HTML tag/element
- Remove a category from a post when saving a new post
- How to edit the Tags within the image file URLs?
- Function filter breaking tag archive menus
- Tags break custom Excerpt function
- Numbering lines of code with the tag?
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- Randomizing wp_tag_cloud() in child theme
- Get term slug by term id and then explode it
- Sort and display pages with specific custom field (not tag)
- Function to echo (or display?) wordpress tags in the head section
- How to get taxonomy tree ids without running expensive loops
- Using get_terms for custom taxonomy in functions.php
- What is wp_get_post_tags for media tags?
- Allow user only create specific tags
- I am trying to set post terms to a custom taxonomy
- I want to customize the_posts_navigation function by replacing prev and next with images
- Why is the term of my current page not returning a slug?
- Removing sanitize_title_with_dashes Function with The Real Title
- method to fetch entire tag list on archive.php
- require_once() Causing categories and tag pages on dashboard to not refrsh
- How to prevent multiple custom terms from being created
- Custom taxonomy not refreshing page on add
- Automatically add tag if a checkbox is checked
- getExcerpt: Make ellipsis appear only if character limit is reached
- Make WordPress search for only this tags or exclude certain tags from search [duplicate]
- How to get tags and categories?
- wp_get_current_user->user login returns %20 for spaces
- If two tags in the middle i need comma
- Display function from functions.php in tag.php
- Bulk set Post Title as Tag where Tag is Empty Function
- delete_term is not working properly with add_action()
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Prevent “main” WPMU site_url() being returned in functions
- How to redirect to post if search results only returns one post
- Get recent posts with thumbnail
- how to create shortcode in wordpress
- Function returns different value when called from ‘save_post’ than when called on page load
- Displaying a random user with a shortcode
- Assign category using custom field?
- Display a function using AJAX
- Updating users_can_register option?
- Changing post category from dropdown
- img width and height attributes being set by get_the_post_thumbnail
- How to properly add NPM packages and integrate them in WordPress?
- Custom function in My Custom Functions returning 403
- Remove H1 / title / Underscore – without CSS
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- functions.php How to add css/js depending on Template Name?
- Wp_query function to search from product_title ‘OR’ product tags name
- Why is my page feed returning empty content?
- Add other social networks to TwentyNineteen_SVG_Icons class in child theme?
- Redirect to another page if the user is logged in when pressing again the login button on menu bar
- Accessing two databases wordpress
- Add a jQuery Function
- Redefine function arguments before rendering
- How do I change a parent theme’s function through the child theme?
- Enqueue script on every page except one
- Best way to handle lack of titles in microblogging
- Redirect to other page if login
- first paragraph of the_content as meta description
- get_terms (or tax_query) for term of current post?
- 404 when enqueue_script using plugin_url
- How to use get_posts() function in functions.php
- How Can I add a menu to the theme from withen the function.php file
- WordPress – using sessions?
- Trigger email alert if file downloaded
- Completely Disable WordPress RSS Feeds
- How to hide content on mobile in the functions.php file – woocommerce
- WordPress Lite/Light
- Selecting specific query for offset
- Is_Page doesnt detect my page
- Show image after X para – center aligned
- Problems adding a new field to product in cart
- function replace_text for entire page
- Zip all (original) images from media gallery
- How to exclude posts with empty and non-existent relational custom field with meta_query?
- How to replace words in my posts and saved new words
- Problem in shortcode outputting content
- Why does modifying my functions.php file always result in a server error
- Echo custom field value in shortcode function
- WordPress Comment functions
- Disable every rss feed except home feed
- Explode Array from Repeatable Custom Field