I modified your code just a bit. See if this works
if ( ! function_exists( 'the_post_limit' ) ) {
if ( true == get_theme_mod( 'the_post_limit', true ) ) {
function the_post_limit( $query ) {
if ( is_admin() || ! $query->is_main_query() )
return;
if ( is_home() ) {
// Display only 1 post for the original blog archive
$get_default_posts_per_page = get_option( 'posts_per_page' );
$query->set( 'posts_per_page', $get_default_posts_per_page );
return;
}
}
add_action( 'pre_get_posts', 'the_post_limit', 1 );
}
}
Related Posts:
- Disable External Pingacks on WordPress Posts and Only Allow ‘Self Pings’
- How can one utilize a variable as a callback function name for add_settings_field
- New Plugin Review
- Use template for posts with a particular category grandparent
- Query all posts of a custom taxonomy term
- Get post id in a function when edit/add a post
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- Which PHP page is the Default Posts Page
- Function works everywhere, how to keep it to execute when creating a new post
- Pagination on Custom Post
- how to save checkbox data for custom setting?
- How to use mysql LIKE with wpdb?
- get post id from wp_insert_post for get_template_part
- remove specificly the last tag in all posts
- How to Send Pingbacks for all Posts in WordPress?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- posts_per_page displays only 2 posts instead of 4 posts
- Send POST request to Flask app from functions.php file
- How to center all text body in single.php at once?
- Getting page / post URL on publish and / or update
- Displaying POST content with HTML tags and all
- Using Tag Groups: Displaying groups and adjacent tags of current post
- How do I get the featured post to share on Social Media and show on Individual Post pages?
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- Weird Behaviour: Not all WordPress Posts appearing
- Published custom posts missing
- WordPress get_post_meta issue
- Insert wordpress tags below posts via functions.php
- Trying to see if page is category or single and displaying title with appropriate heading tag
- How to modify this function to exclude also the post belonging to a specific category?
- How to display the date under the post title?
- Add multiple HTML attributes to an Elementor button
- WooCommerce: write featured image dimensions to custom fields in product’
- How do I get a function to work in single.php
- transition_post_status hook, works – but not if the post is new
- How to change post date and post time in WordPress automatically with a function
- How can I use wp_insert_comment to write a comment when a post is edited?
- Why use the Settings API over a new administration menu?
- Using Multiple Submit buttons to trigger customised php functions
- Removing unneccessary p-tags (Not every p)
- How to remove the excerpt in the Dzonia Lite theme
- comments_number display outside specified span
- Choose To Display Post Views With An Options Panel
- Prevent Data Resubmission On Page refresh
- Set WordPress Default Template
- Remove posts after a given amount of time
- Shortcode content filter?
- Automatically add custom CSS to new posts using a category template
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- How do I display a user’s previous orders as a select box option on a product?
- How Display Posts on category
- Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false
- Hide wordpress field if data is empty in post!
- allow subscribers to see private posts without plug in
- Replace word in “the_content” only for index.php
- How do you add customer capability after Woocommerce purchase?
- How to get specific image in media library with php
- Function set default image when image not present
- How can I use wp_query to show all product data using just the products ID?
- Implement toggle switch for theme options in settings API
- Custom location for attached images
- WooCommerce – Reset quantity input field when variation changes
- get current product name in functions.php
- Retrieving Author ID in wp-admin area
- Get first URL from post content
- Setting custom canonical urls
- Handling Body class based on Template
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- Get_avatar filter?
- Can’t get page content in WordPress
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- Way to querry data (tags) from a wordpress database?
- get post based on category chosen in drop down – The ajax method
- Adding Default Settings to Theme My Login plugin
- Image as Sales Badge
- how to make separate field in wordpress user_data_
- Getting a specific post values to another div or modal
- Function not working at one place
- jQuery not defined
- Displaying the Month and Year that a page was Created?
- Changing custom logo link
- Add a class to the anchor tag on HTML5 gallery
- Trying to add attribute to my posts’ featured image
- Conditional Header in wordpress
- Remove meta description on certain pages
- Menu — How to add “current-menu-grand-ancestor” css class
- Set the checkbox as checked by default at options page
- Use menu link or onClick to set a variable
- Swapping wp_dropdown_categories function with wp_category_checklist
- functions.php is being included twice, creating PHP fatal errors
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Automatically remove a canceled order in Woocommerce
- Display fields as values in array from external SQL DB
- Only Show Link If div Exists
- Displaying the last post on static homepage
- How to put a variable in a instance in the widget
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Can’t get wp_insert_post to work