You can try to add the condition $query->is_main_query() in your if-sentences so it won’t affect the gallery queries:
// Posts per page
add_filter('parse_query', 'wpq_parse_query');
function wpq_parse_query($query)
{
if(!$query->is_main_query())
{
return $query;
}
if($query->is_archive())
{
$query->query_vars['posts_per_page'] = get_option('to_count_archives', 1);
}
if($query->is_home())
{
$query->query_vars['posts_per_page'] = get_option('to_count_home', 1);
}
if($query->is_search())
{
$query->query_vars['posts_per_page'] = get_option('to_count_search', 1);
}
return $query;
}
Related Posts:
- wp_enqueue_script was called incorrectly
- Remove type attribute from script and style tags added by WordPress
- Customize WordPress Media Manager – Media Window
- How to display error messages using WP_Error class?
- Gallery images titles – get from post
- Remove Menu Page Giving Error
- Functions.php reverted to new one
- Why is my Gutenberg block returning an error after initial save?
- How to use thumbnails in gallery?
- Debugging with functions.php
- Display gallery on top before content
- Converting html to wordpress images not showing
- Default Gallery Edit/Template Editable?
- Shortcode pagination not advancing
- How to add ‘data-caption’ inside an anchor tag
- Help with WP gallery function, wrap gallery in div
- how can I edit flexslider in woocommerce. [Urgent]
- Warning: : DOMDocument::loadHTML(): Empty string supplied as input in functions.php when adding classes to post images
- Custom Attachment Caption Fields
- Parse error after modifying the template menu [closed]
- Display gallery on bottom after content
- watermarking gallery items
- help I changed one currency in woocommerce and everything is ruined [closed]
- Need help getting a function to function
- Connecting to a 2nd DB gives me no results when querying
- debugging errors.. how to remedy?
- Native gallery custom html output
- Strange error from functions.php files (wp_register_script)
- Check if a different page has any attached images
- Show errormessages on wrong username/password on custom loginform?
- Problems with functions.php! Error! [closed]
- Looking for Functions File that doesn’t Exist
- Render metabox gallery in frontend
- functions.php pharse error on complete new install
- a SET of wordpress native galleries with title and text?
- Customise the WordPress gallery html layout
- “Conditional query tags do not work before the query is run. Before > then, they always return false. “
- MCAPI.class.php showing some error
- I’m getting invalid taxonomy in init action
- Translation Function missing text-domain [closed]
- What is wrong with functions.php? Fills error log with same error
- Move captions under gallery images in twenty fourteen theme
- Random text changing to weird icons in both admin & front end
- Remove Captions from Custom Gallery function.php
- jQuery HoverIntent is not a function
- Add gallery id to rel attribe of wp_get_attachment_link
- create submenu page – error function not found or invalid function name
- Why does modifying my functions.php file always result in a server error
- Gallery Shortcode Function Help
- Notice: Use of undefined constant REQUEST_URI – assumed ‘REQUEST_URI’ in ….functions.php on line 73
- Woocommerce – Checkout error message
- How to fix enqueue_styles error for a twenty-seventeen childtheme
- Comment turned Invisible
- Logout redirect via page template without confirmation?
- Convert Image to Webp on upload without plugin
- Uploading images via ACF update_field function
- Rewrite standard $errors messages output via function.php
- remove_action on after_setup_theme not working from child theme
- How to reduce original image quality on upload?
- Shortcode with parameters inside parameters
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Enqueuing Script in functions.php vs on the page
- What does the author_nicename parameter do in get_author_posts_url()?
- Add caption functionality to custom WordPress theme
- List all-childpages on parent-page AND list child-pages on childpage itself but not the current one?
- Default Custom Field Value Automatically Update
- meta tags doesnt fetch data from permalinks
- Show image exactly defined to a width
- Is `is_sidebar_active()` deprecated, and showing error?
- How to return hook data when multiple parameters are present?
- How to add_filter html template to middle of content
- Some questions about how proper add 2 CSS file in a WordPress theme?
- How can i unload effect.min.js file?
- Auto scroll to id on page load on all pages except home page. Only do this on mobile
- why is this function firing on all child menu items as well?
- Custom styles in Tiny MCE with an external CSS file
- I changed Functions.php and now I get “cannot decode raw data NSURLErrorDomain:-1015” (not blank)
- Use add_action within template
- contact form in template with jquery,validate and ajax
- Changing the header image using WPML
- current_page_item is missing inside wp_nav_menu
- How to add if statement on WordPress shortcode output
- How Do I Unhook This Parent Theme Function?
- Woocommerce product price change
- How to create an array if ’empty’?
- i can’t use wordpress functions in ajax loaded php file
- Woocommerce – Switching Price for Category
- How to create a WordPress Customizer Button to Clear a Cache?
- Javascript and Stylesheet in child page
- Custom Nested WordPress Comments with avatar
- Having problems loading Jquery in functions.php
- WP Debug enabled Undefined index error in a widget
- How can I append and prepend something to all post hyperlinks without using ::before or ::after? PHP hook solution?
- How to overwrite ‘read more” text for artmag theme
- Retrieving next_post_link() and previous_post_link() in functions.php
- WordPress Custom wp mail template return full template
- BuddyPress Edit activity function good practice
- wp_login_form display no styled form
- Would it be possible to disable embeds for specific user roles? If so, how?
- i recently bought a theme and when i try to activate it says (It appears wp_remote_get() function is disabled in your server. )