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()
- Overriding an existing filter
- Missing feature image link function
- What’s the difference between home_url() and site_url()
- Remove “Category:”, “Tag:”, “Author:” from the_archive_title
- get_template_directory_uri pointing to parent theme not child theme
- Is There a Difference Between Taxonomies and Categories?
- How to customize the_archive_title()?
- remove empty paragraphs from the_content?
- What is the “with_front” rewrite key?
- Why use if function_exists?
- How to override parent functions in child themes?
- wp_enqueue_script was called incorrectly
- Add multiple custom fields to the general settings page
- Ajax call always returns 0
- 400 bad request on admin-ajax.php only using wp_enqueue_scripts action hook
- How long does a deprecated function live in core?
- Solution to render Shortcodes in Admin Editor
- How to add a data attribute to a WordPress menu item
- What’s the difference between esc_html, esc_attr, esc_html_e, and so on?
- remove_action on after_setup_theme not working from child theme
- plugins_url vs plugin_dir_url
- Remove type attribute from script and style tags added by WordPress
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- Upload Multiple Files With media_handle_upload
- How to display custom field in woocommerce orders in admin panel?
- Adding fields to the “Add New User” screen in the dashboard
- Issues with title-tag and document_title_parts
- How do I get the current edit page ID in the admin?
- How to check if a user exists by a given id
- Why isn’t is_page working when I put it in the functions.php file?
- Add tags to the section via functions.php
- Add image size if page template
- How to create a custom order status in woocommerce!
- Remove Actions/Filters added via Anonymous Functions
- Adding a second email address to a completed order in WooCommerce [closed]
- How to load parent_theme functions.php before child_theme?
- How to load scripts/styles specific for a page
- Programatically add options to “add new” custom field dropdown
- Is there any global functions.php file which works for any theme?
- Excluding iPad from wp_is_mobile
- When should you, and when should you not, use wp_list_pluck()?
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Difference between the_permalink() and get_permalink() function
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Child theme – Overriding ‘require_once’ in functions.php
- How to not allow users to create new tags, but allow to them to use existing ones
- Link to user’s profile settings page?
- WordPress Enqueue for homepage only, functions.php, wp-framework
- get php variable from functions php and echo it in theme template files [closed]
- Get menu object from theme_location
- Is it ok to use a function to output the text domain name in a wordpress theme