To automatically flush permalinks every hour, use the following code:
- Hook the scheduling function to
init
. - Schedule an hourly event if not already scheduled.
- Hook the scheduled event to a function.
- Define the function to flush rewrite rules.
// Hook the scheduling function
add_action( 'init', 'schedule_my_hourly_event' );
// Schedule the event
function schedule_my_hourly_event() {
if ( ! wp_next_scheduled( 'my_hourly_event' ) ) {
wp_schedule_event( time(), 'hourly', 'my_hourly_event' );
}
}
// Hook the event to a function
add_action( 'my_hourly_event', 'my_flush_rewrite_rules' );
// Function to flush rewrite rules
function my_flush_rewrite_rules() {
flush_rewrite_rules();
}
Related Posts:
- how to get permalink structure with php
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- wp_trim_words() does not work with my code Am I doing any mistake in my code?
- WordPress theme showing blank page
- Permalink changes after several minutes after saving post
- What is the proper way to call a function (from functions.php) on a link click?
- redirect 301 with special character like WIX site “#!”
- Accessing WordPress Functions get_permalink() in Vanilla PHP?
- How to extract URLs from wordpress taxonomies
- Execute wp_after_insert_post after the permalink is customized
- Modify the permalink structure for a specific category
- Is it possible to go to the next post in the same category?
- Processing data and redirecting with query string
- Passing the custom field values in the wp_get_current_user array function
- Using fwrite() and “a” appends multiple times instead of once
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- How to style options page in dashboard?
- How to insert a single row to WP database table?
- Get date numerical and separate?
- Add prefix to link url
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- WSoD being caused by this piece of code
- Converting HTML Template to WordPress Theme
- Set the background to a default image if there isn’t a specified “featured image”
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Add a variable in functions.php and call it in single.php
- How to access global variable $menu inside a class function
- Calling directories to load in wordpress
- WordPress add post format support not working
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Image media upload metabox
- How to remove the cufon script from Dzonia Lite theme [closed]
- How to remove or change the “W” icon in “My Sites”?
- get a simple array of all of the term names that exist in all taxonomies
- Login/logout in header
- How to display posts by current user in a drop down
- Logged in user ID as post ID
- How does WordPress insert Paragraphs in posts
- WordPress Access allowed to fewer pages till user logs in
- Linking text within textarea of custom meta box
- Show css depending on activity type in BuddyPress activity-loop [closed]
- only show container with next/prev links if they exist?
- How to combine wordpress_logged_in cookies in one cookie?
- Populate dropdown with Child Pages based on Parent Page chosen
- How can I remove a function that has been added to wordpress with add_filter?
- 200 Rewrite blog post links
- Change the WP Video Shortcode Output
- Show categories then when clicked on a category list all sub category and when clicked show all posts in that sub category
- remove wp floating submenu in wp dashboard
- How to put “Read more” link in Custom Excerpt inside p tag?
- Two Different Links for Same Product – WooCommerce [closed]
- ACF: how do I get the fields and its values of a specific group?
- How to store data from multiple forms using ajax and php
- How to control WordPress image metadata (using Imagick)?
- How to add seperate classes to no-search-result and found-search-result pages on wordrpess search – is_search()
- Get value from shortcode to do something
- PHP 8, AJAX mail form to function.php doesn’t work
- How do I add custom bulk actions to multiple custom post types?
- Error when adding excerpt to the content through functions.php
- Automatically adding new post categories to menu
- Add data attribute to each li in menu
- Get post id in a function when edit/add a post
- Making BuddyPress Activity Stream (Post Type) Featured Images Clickable [closed]
- How to check if a meta value has already been assigned to any user?
- How to complete two other input fields, completed the first
- Prev/Next child navigation for current page modifications?
- Adding rel tag to all external links
- php script to change slug in post automatically
- How can I apply_filters from inside a function?
- function to assign user role based on a field from usermeta
- what is the best practice to add new field to an api route
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Use DOMDocument with ob_start breaks my HTML code
- Auto-update products after they were published – Woocommerce
- How to prevent WP_Query function from returning all posts when empty?
- JS file work only in index page
- Display a specific category of products in shop page and disable code for specific actions
- Woocommerce related product text
- esc_html_e() is not translating string in wordpress [closed]
- Removing “wpautop” (auto tags) only on certain pages?
- Fatal error: Uncaught Error: Call to undefined function test()
- How to pick the default selected value in wordpress dropdown?
- Using WP-API and SSE not authenticating user ID
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- Validate functions before inserting then into functions.php
- How to retrieve current wordpress profile page URL?
- Firing schema via code in functions.php doesn’t work
- A non-numeric value encountered in /wp-includes/functions.php on line 68
- Get page that displays all children of taxonomy parent
- Changes in permalink structure in WordPress and how to apply to in-site links
- WordPress Persistent connection rule does not work for “posts”
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- WordPress every page is 404 not found including admin resources
- get author_name from queried post
- WordPress returning 404 for multisite pages
- Why ajax doesn’t work on certain wordpress hooks?
- How to use $_GET function WordPress backend
- Is it possible to intercept all ajax requests and get the parameters and the returns?