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
- How to add a data attribute to a WordPress menu item
- Relative URLs and hide /wp-content/themes/
- Slugs as breadcrumbs for Pages
- Removing Unnecessary Text from Admin Menu without CSS
- Display WordPress Search
- Remove_filter (‘the_content’, ‘wpautop’) is not working
- Clean-up script tags
- WordPress function for 1 to for many
- How can you limit srcset on a single type of page?
- How to fix Warning: call_user_func_array()?
- I want to get product attirbute in the section below
- Restore Image Title Text
- Full page template function
- Redirect from “private” page and functions.php which tag add to add_action()?
- Storing password (functions.php)
- Check if the image size is available and if not use ‘full’ image size
- get_next_posts_link() returns no result despite available posts
- Randomizing wp_tag_cloud() in child theme
- Nav menus all outputting the same links
- Secondary Menu and Logged In Users
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Adding code before post title with the_title produces weird results
- Add Link to Users List (Backend) to open each users front-end profile
- Editing the formatting.php file vs functions.php file?
- wp_usermeta – Read from database, but save function broken
- remove/hide wp-editor
- Function not saving unchecked checkbox
- Entirely Different Functions.php per Page?
- Problem with shortcode inside a shortcode
- Hide Author By-Line if After Certain Date
- wp_title() return random number
- How to offset main query without affecting other queries and backend
- How to add link rel tags on paginated posts?
- How to pass data from a plugin to functions.php
- Function to disable “href” anchor tags that contain “a data-name” on mobile only
- Execute jQuery with custom event listener after successfully add an item to the cart
- WordPress hooks to call a function inside a construct
- Load a Child Theme’s style.css just before the closing tag
- Can’t wrap my head around this function – any help would be appreciated
- Figure inlined width trigger distorted layout
- Exclude javascript in certain page url and all following url’s after forward slash
- Shortcode Variations?
- How to test for a class (from a plugin) in functions.php
- Child Theme not working – CSS gone
- Which template file to edit to edit homepage in Mystile [closed]