I ended up with this solution in functions.php
, thanks to the offical WordPress documentation at: https://codex.wordpress.org/Rewrite_API/add_rewrite_rule
First added a custom rewrite rule like so:
function custom_rewrite_rule() {
add_rewrite_rule(
'^agenda/([^/]*)/([^/]*)/?',
'index.php?page_id=10&agenda_id=$matches[1]&agenda_name=$matches[2]',
'top' );
}
add_action( 'init', 'custom_rewrite_rule', 10, 0 );
Then this needed to be added:
function prefix_register_query_var( $vars ) {
$vars[] = 'agenda_id';
$vars[] = 'agenda_name';
return $vars;
}
add_filter( 'query_vars', 'prefix_register_query_var' );
Now URL’s such as /agenda/1/event-title work like a charm! And passes the variables needed.
PS: Remember to save the permalinks settings in the backend once again, or this code won’t work!
Related Posts:
- using add_action for a header hook that has an additional parameter
- Error in custom php function doesn’t exist
- How to remove woocommerce_breadcrumb() from do_action( ‘woocommerce_before_main_content’ ); [closed]
- Theme not calling Jquery properly
- WordPress Themes and PHP unit
- Receiving Stripe Webhooks on a wordpress website
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- Dynamically change feature image in customiser
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- Design view breaking on Pages
- Adjust the results quantity for Search Results page pagination
- Hooking new functions to actions + passing parameters
- Replace existing content from specific WooCommerce admin orders list column
- Passing array in add_option()
- Is it possible to use the featured image of a page as a css background without inlining?
- How do I translate this string – PHP syntax question
- Site Health : An active PHP session was detected
- enqueue hover function
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to display recent posts on home page with custom HTML
- WooCommerce: Add Payment Gateway Field to Webhooks [closed]
- How to call function at the bottom of post using plugin?
- Using a `Template Parts` folder instead of an `Includes` folder in a Custom WordPress Theme
- Multiple WordPress Menus that will only display all pages
- How to show part of the_content?
- Hide categories that are not used in the post type
- How do I add custom bulk actions to multiple custom post types?
- what is the best practice to add new field to an api route
- Grab posts by multiple categories
- Reload part of checkout on changed shipping method
- Remove a div from RSS feed
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- Set meta field to publish date + 2 weeks
- WordPress Gravatar filter is removing my custom attributes
- Customizer: active_callback and sanitize_callback incompatibility?
- Are all hooks/functions tied to Kses meant for sanitization?
- Should `wp_login` be used since it’s deprecated?
- Use WordPress function in php file
- Omit custom post type from wp-sitemap.xml based on meta key using wp_sitemaps_posts_query_args
- How to use a custom hook
- WordPress Customizer Default Image
- Theme’s Options Page included with require_once *.php in functions.php not visible anymore
- How to show an entire post content and not also the excerpt?
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Get access to variable from previous pageview, excluding ajax-calls
- WordPress redirect redirecting too many times or not at all
- How to add the sidebar to all the pages except the home page? [closed]
- Header not properly displaying on archive.php
- How to have different site identity logos on each page on Astra Theme [closed]
- Get post categories
- Comapare get_user_meta value
- Removing “Powered by” footer using child theme PHP [closed]
- Unable to access WordPress functions from functions.php
- Output only links using wp_nav_menu()
- How to add aria role and schema markup to custom walker container
- jQuery accordion menu
- pass html code to worpdress
- Commas in Tag Cloud
- Trying to change featured image from 180×180 to full width on home page
- security concerns if using html data-* attribute for l10n?
- WordPress redirects page query parameter in URL
- Getting text from custom field from customizer
- WordPress navigation wont appear with wp_head
- save_post trigerred twice
- How do you create a custom category widget that you can style?
- Replace a single variable with add_filter
- Removing “There is no account with that username or email address.” error message in “/wp-login.php?action=lostpassword”
- How to change basename url for wp-admin?
- Prevent header and footer from loading on specific pages with template or plugin
- Contain multiple page templates in one PHP custom template file in WordPress?
- url not using query string no longer working
- Not able to remove caption shortcode from the content
- Wp_Schedule_Event every few minutes doesn’t work
- Weird fonts showing which are coming from database
- require get_template_directory() . ‘path/to-my/file.php’ BREAKS customize > themes functionality
- Trouble Accessing Gravity Forms API (GFAPI)
- How to have different headers.php files based on the display page
- alternate left – right content inside the loop
- How do I get the value of a current user’s custom field?
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- Proper use of Output Buffer for a whole php clas
- Fatal error when using array_diff() function inside of wp_update_nav_menu hook?
- CSS loading as empty file in Custom Theme
- Woocommerce variable products are being added to the card on the homepage (ajax)
- How can I customize a WordPress theme before it’s downloaded?
- Create a custom theme-specific page, invisible in the admin-panel?
- Trying send mail from Theme page
- A Customizer checkbox control that sets the setting to “” or to “blank” and show() or hide() a color control
- Image not displayed
- WordPress causing all code to be displayed on line 1. Receiving multiple errors after cleaning cookies and cache
- Shortcode working in page.php but not in category.php in wordpress
- Adding a Sub Menu Options Page WP Backend Menu. Whats wrong with my code?
- Cannot modify header information – headers already sent
- How can a ‘scripts’ directory be hooked into wp_head();?
- Send a custom notification to customer on WooCommerce cancelled order status
- WP and Laravel integration (Updated) [closed]
- paginate_links() returns NULL instead of the pagination links, but pagination is actually happening
- Variable ++ in query loop
- transition_post_status hook, works – but not if the post is new
- Woocommerce – add tracking code to another email template