Just make sure you’re not in the admin when changing the query:
function num_posts_archive_project_ie($query) {
if (!is_admin() && $query->is_archive('projects-ie') && $query->is_main_query()) {
$query->set('posts_per_page', 6);
}
return $query;
}
is_admin()
does return true only if you’re in the backend (it does not, however, verify that the current user is an admin user, despite the name, don’t let that confuse you), so that hook won’t change anything in the backend post list.
Related Posts:
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- Image loading function not working on archive.php template
- Detect Ajax call inside pre_get_posts function
- Pagination not working on my archive page for a custom post type
- Archive.php, and post_is_in_descendant_category
- What’s the difference between WordPress random_int() and PHP built-in function random_int()?
- Is it ok to use a function to output the text domain name in a wordpress theme
- Issue with wp_get_attachment_image() and SVG file type
- deregister scripts on certain page
- Custom menus displaying all pages instead of set pages
- Show Video in Excerpt
- How Can I Access a PHP Variable in Another PHP Function
- How to fix a theme with page.php Default Template that accidentally deleted?
- Override parent theme function that is not hooked or in the functions.php file
- Theme Demo in live Site
- function to include is_home, is_archive, is_category, is_author etc in one function?
- How to remove canonical url in wordpress? add_filter( ‘wpseo_canonical’, ‘__return_false’ ); not Working for me
- Change a sidebar name?
- Removing title from page
- get_the_excerpt() not returning anything when post has no excerpt
- Why isn’t is_page_template() adding a body class?
- Query children and parent title
- How to make unique add_filter to the_content of specific page template files – so each template gets its own addition
- Creating loop within functions.php
- Limit filter upgrader_post_install to a single plugin
- How to test for Super Admin
- How to use max and min values of custom fields
- creating shortcode to pull json array
- Still relevant method of embedding images in WP Theme in 2018
- Pass Shortcode Attribute to footer Script
- How to use Internationalized human_time_diff() function in Chinese?
- post to subcategory and parent in wp_insert_post
- Variable if post is sticky in functions.php
- Execute a ultimate member action when user role is updated
- Create a new query in function.php to filter blog posts
- Use third party Library in wordpress
- Remove the product category module block from the Woocommerce product page
- Creating new blog on multisite programatically without hacks?
- Allowing users to view private posts (pending approval)
- How to get correct URLs in network wide menu (Multisite)?
- Remove category from url
- ‘Attempt to modify property of non-object’ warning
- Conditional functions.php on page template
- Optimizing a WordPress site
- different style sheet for just one page template
- Problem with comments_number()
- How to add custom JavaScript in functions?
- How to target post and pages and not all post types in admin?
- srcset and custom field get_post_meta and wp_get_attachment_url
- hide shortcode using hooks
- Dequeue script to prevent javascript event conflict on wordpress child theme
- Adding code using functions.php in child theme
- Passing global variable from header.php to functions.php
- Extending a custom framework built into WordPress to automatically turn the ‘Search Engine Visibility’ setting ON / OFF, dependant on environment
- Page get parameter doesn’t work with is_single() function
- How is $current_page passed in woocommerce_account_orders function?
- Upgraded server now class My_Walker_Nav_Menu extends Walker_Nav_Menu not working
- Filter to wp_list_authors
- Contact Form 7 If Condition
- How to include any template using Shortcode fuction?
- display a div on ervery site but not frontpage?
- How can I change the size of the text in Word Press
- Using depth=n in wp_list_pages
- shorthand syntax for custom fields
- How do I pull avatar from post using BuddyPress? [closed]
- Replace header image on all other pages but home – URL issue
- Child theme functions.php
- Show admin page, only if function is being used
- Get users with different roles and call function on each of them (user_meta)
- Getting images from media library and get_the_date() not working
- WordPress show bad the php hour and date
- Show errormessages on wrong username/password on custom loginform?
- Using add_image_size in functions.php to get original uploaded file
- How do I change where “You must be logged in to comment” directs users?
- Login cookies blocked after customizing hashing method
- How to add specific terms in a custom post type?
- Class parameter in get_avatar args doesn’t get added to output
- Why is my archive page looping through all but one post?
- Enable CORS Request for hostname using IP address
- Extend WordPress Audio Widget to accept HLS (.m3u8) URLs
- locking content with overlay/pop up ads
- How to use `foreach()` in ajax call
- Change default color scheme in twentyfifteen child theme?
- Restrict access if logged out except for homepage
- DISABLE wordpress upgrade page
- How to list out all values from the get_body_class array
- Moving CDN jQuery to footer does not work?
- Mail function not working with user accounts
- Function not recognizing page id?
- Register a widget area when a theme option has been saved?
- Blank child theme – functions.php problem
- Conditionally write open graph meta property in header
- Pull random comment from specific post, display on homepage with shortcode
- Give a function a unique ID
- Hiding Google Analytics code based on theme options
- Text before price on WooCom
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Change Post status based on custom field date +1 day
- How to add height and width dimensions automatically to archive descriptions
- How to store page-{id}.php templates in custom folder