Try these steps:
Step #1: Replace this:
add_action('generate_rewrite_rules', 'custom_rewrite_rules');
function custom_rewrite_rules( $wp_rewrite ) {
$regex = '/[\s\S]/';
$new_rules = array(
trailingslashit('testimonials/'.$regex) => '/?p='. get_page_by_path('$matches[1]', OBJECT, 'post')->id
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
return $wp_rewrite;
}
..with this one:
add_action( 'init', 'custom_rewrite_rules' );
function custom_rewrite_rules() {
add_rewrite_rule(
'testimonials/([^/]+)(?:/([0-9]+))?/?$',
'index.php?category_name=testimonials&name=$matches[1]&page=$matches[2]',
'top' // The rule position; either 'top' or 'bottom' (default).
);
}
Step #2: Go to the Permalink Settings page, and click on the Save Changes button without actually making any changes.
Related Posts:
- What’s the difference between home_url() and site_url()
- Prevent “main” WPMU site_url() being returned in functions
- Custom page with variables in url. Nice url with add_rewrite_rule
- Is it possible to use a forgot password url filter?
- How can I rename the WordPress AJAX URL? [duplicate]
- Ninja form Redirect depending on text field content [closed]
- wp-comment author- url +, email filter hook
- Removing custom meta data
- WordPress on AWS Auto scaling and ELB giving 503
- WordPress converts media extention URL automatically to video player
- meta tags doesnt fetch data from permalinks
- Get arguments from URL
- Add unique id to Preview URL
- How can I set the SRC URL of the custom logo image?
- Need to convert image url to a Base_64 data url with wordpress function..
- Protect get_query_var from manual input in url
- Problem with images URL after filter applying
- How i can get the URL?
- include w_thumbnail_src in function?
- Create Custom URL structure for specific Post category using Post ID instead of post name
- Fetch URL parameter
- how can I change all wordpress media file url to custom cdn url?
- Custom route and extract data from slashes and parameter
- reWrite wp-content url to point on my cdn
- How to Override Page Template if URL matches query?
- Add #primary at the end of navlink permalinks on single posts
- Set URL Parameter Post Layout As Default
- Using Switch Statement to Change Image According to Last Digit of Topic ID
- Instead of using $post, how do i get the thumbnail image of the $post
- How to add a meta information to the URL?
- How do I change the URL returned by next_posts_link()?
- Function in functions.php by url
- get php variable from functions php and echo it in theme template files [closed]
- Use AJAX in shortcode
- WordPress function like is_category for subcategory? is_subcategory?
- WordPress Theme Update Action?
- Using a private method as an action callback from within a class
- Auto close (hide) custom metabox / set default state
- Does WordPress Development Mode Exist (with not minified JS)?
- WP_Query in functions.php
- How to override functions.php in child theme?
- Is it possible to maintain image aspect ratio when scaling images?
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- change a post status when users update posts?
- How often is functions.php loaded?
- Display height and width properties with the_post_thumbnail() or related function
- Cleaner way to access custom fields in code?
- Add a new subscriber role using a function
- Display a text message if the shortcode is found?
- How to store / access files in child theme folder
- How to set the jpg image compression for specific thumbnail sizes?
- Function to auto-set a featured image that is already in use
- How would go about if I just want a temporary function?
- How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- How to hide unused profile fields?
- Override widget in function WordPress
- How to change or add user role after getting post request data about pay? [closed]
- Automatically include all php files in a child theme directory
- Add a unique class to HTML tag/element
- Removing specific menu items?
- Which function required?
- AJAX error handling for submit function in functions file
- get_pages() Returns Only One Item
- Use a shortcode to display custom meta box contents
- how to make has_block() see inside blocks too
- Getting the teaser text without overriding global variables
- add_theme_support( ‘title_tag’ ) is not showing title on index.php
- Solution dealing with Child Theme / Parent theme functions
- Function to pull data from user meta not working
- is_product_category(‘Services’) not working
- Replace theme function
- How to access custom class methods from any include without using global
- More than one search results page template for two searches on site
- How do i create a search option for pdf’s only
- What is best practices to move the following code into a function?
- Restrict certain roles registrations by domain
- Replacing term/taxonomy archive pages with search queries
- Return ACF Field value function
- Best way to add image to recent posts widget?
- wp_enqueue_script only works outside of action
- How can I include user meta information in the resulting array of a WP_User_Query?
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Force changing the Site Title and add link
- create submenu page – error function not found or invalid function name
- Get Value of Custom Field
- Undefined offset: 2
- Need a functions that adds (adm)/(mod) if current user is admin/moderator right after their username
- Using is_plugin_active within functions.php
- Add title & subtitle to shortcodes
- Button generate a random URL [closed]
- How to Delete Posts by title?
- How do I add functionality to images?
- Display function from functions.php in tag.php
- AJAX values converted to PHP Variables?
- How do i set global variable in a function in wordpress functions.php
- Working function() doesn’t execute when triggered by WP CRON
- WordPress – Notice: Function wp_enqueue_script was called incorrectly
- post_row_actions filter from parent theme not executing in child theme