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
- warning: trying to access array offset on value of type bool ACF field image group
- Uploading images via ACF update_field function
- Rewrite standard $errors messages output via function.php
- 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
- 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?
- 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
- How to run a function every 5 minutes?
- Best way of passing PHP variable between partials?
- How to manually fix the WordPress gallery code using PHP in functions.php?
- 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