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
- Child theme – Overriding ‘require_once’ in functions.php
- Display custom comments field for first level only
- How do I get the author’s page url from their ID?
- Limit the length of the Author Profile Biographical Text
- disable comments if array exists
- WordPress Change Post Templates,but not drop down, but Image selection
- wp_mail not running inside Cron
- Remove images from get_the_excerpt
- Remove “says” from comments
- Reuse variable in hook callback
- Logging in redirects to correct page but shows logged out content until forced refresh
- What is the criteria for pluggable functions?
- Can you use admin pages functionality on the frontend of your site
- How can I stop a function from encoding an entity?
- Theme-Config tab in admin Pannel?
- Display more recent and less recent posts in same category
- Function to “Press Update Button” on all posts
- Change WP attachment name to postid during upload only for post type
- Overwrite Parent Theme add_image_size in Child Theme
- Missing argument 2 for a custom function widgets_init
- How to target only the front page (not subsequent paginated pages) in theme/plugin?
- Get the 5 lastest Featured Posts from a category
- Is it possible to change any of the HTML/URL returned from the_category()
- Activate small php condition at footer over page template
- How to insert custom widget in custom sidebar in theme activation?
- Writing functions in WordPress functions.php that don’t replace a WordPress core function
- HTTP_HOST changing in functions.php
- 404 redirect to previous category
- show first 3 thumbnails of posts in different sizes [closed]
- Getting custom image size URL in functions
- Remove category from url
- ‘Attempt to modify property of non-object’ warning
- Optimizing a WordPress site
- different style sheet for just one page template
- How to target post and pages and not all post types in admin?
- hide shortcode using hooks
- Passing global variable from header.php to functions.php
- Page get parameter doesn’t work with is_single() function
- How is $current_page passed in woocommerce_account_orders function?
- Upgraded server now class My_Walker_Nav_Menu extends Walker_Nav_Menu not working
- Filter to wp_list_authors
- Contact Form 7 If Condition
- How to include any template using Shortcode fuction?
- display a div on ervery site but not frontpage?
- Using depth=n in wp_list_pages
- shorthand syntax for custom fields
- How do I pull avatar from post using BuddyPress? [closed]
- Replace header image on all other pages but home – URL issue
- Get users with different roles and call function on each of them (user_meta)
- Getting images from media library and get_the_date() not working
- Show errormessages on wrong username/password on custom loginform?
- Using add_image_size in functions.php to get original uploaded file
- How do I change where “You must be logged in to comment” directs users?
- Login cookies blocked after customizing hashing method
- Enable CORS Request for hostname using IP address
- How to use `foreach()` in ajax call
- Change default color scheme in twentyfifteen child theme?
- DISABLE wordpress upgrade page
- How to list out all values from the get_body_class array
- Moving CDN jQuery to footer does not work?
- Function not recognizing page id?
- Register a widget area when a theme option has been saved?
- Blank child theme – functions.php problem
- Pull random comment from specific post, display on homepage with shortcode
- Hiding Google Analytics code based on theme options
- How to cache results of of get_available_post_statuses() function as it is causing a slow query on a website with over 1 million posts?
- post_content return zero!
- Add custom css to specific user