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
- what is correct way to hook when update post
- Why have on every line
- How to check if woocommerce is activated in theme
- Function to return true if current page has child pages
- WordPress Themes and PHP unit
- Using register_activation_hook in classes
- WordPress and event-driven programming – what is it about?
- How to determine if WP_DEBUG is enabled? [duplicate]
- PHP unit testing WordPress?
- Proper use of Output Buffer
- Include a external PHP file into a WordPress Custom Template
- List of all theme customizer control types?
- Need help setting default setting value for radio button in theme customizer
- Custom plugin: Trying to show saved data on frontend
- Get author full name
- Is having multiple theme customizers for different pages possible?
- Receiving Stripe Webhooks on a wordpress website
- How to export/import theme customizer settings?
- Remove Customize Background and Header from Appearance admin menu without CSS or JS
- Remove Woocommerce product link
- How to remove hardcoded characters from playlists?
- Check php version before theme activation
- function_exists call in function.php
- Is it possible to get a theme customizer setting from wp.customize using jquery?
- Debugging an error: wp_enqueue_style was called incorrectly
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Change the footer text on the login page
- reason of splitting theme files to multiple files
- How can I remove “Proudly powered by WordPress” from twentyeleven without modifying footer.php?
- How can I hook into and edit the text of a wp_nav_menu tag?
- How to remove a metabox from menu editor page?
- How to get the registered sidebar’s name by its id?
- is there a simple way to list every templates / php files used to generate a specific page?
- Set the transport of the Customizer ‘header_image’ core setting to ‘postMessage’
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- Dynamically change feature image in customiser
- One button to change all settings in theme customizer?
- Check if page parent has certain template
- Multiple wp_schedule_event cron jobs in plugin cause multi-execution
- Custom HTML structure in wp_list_categories
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Guidance with The Loop for CMS
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Prevent publish status/date saved on transition_post_status hook
- Audio Player not loading when the content is loaded through Ajax, MediaElement.js no applied
- How to use copy() function and paste file in /wp-content/themes directory
- Why isn’t my if/elseif/else working correctly here?
- How to use SRCSET with get_the_post_thumbnail()?
- How to Remove a Filter from the Admin List Table?
- Design view breaking on Pages
- Adjust the results quantity for Search Results page pagination
- Dynamically loaded Theme components based on Customizer Settings values : changes not appearing in Customizer preview – (Workaround found)
- How can I add a class to a single menu item?
- Multiple do_shortcode($content) within one shortcode
- List authors with posts in a category
- Understanding WordPress child theme custom JS loading
- How can I loop into two different DIVS without repeating the DIVs
- Removing unnecessary wordpress files
- Hooking new functions to actions + passing parameters
- Woocommerce, recognize the loop of related products
- Remove css styles from specific page
- Find variables available at a given hook
- Passing data between two hooks in separate HTML requests
- Use different javascript files for each page on website
- WordPress loop specific thumbnail size
- Is $hook a global variable in WordPress
- Replace existing content from specific WooCommerce admin orders list column
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Show different Customizer Settings on Page-Tamplates
- How to get custom image size for image uploaded in Customizer
- Passing array in add_option()
- do not show web page section when using advanced custom fields pro
- Is it possible to use the featured image of a page as a css background without inlining?
- PHP Customization: Taxonomies and Queries, why? [closed]
- Executing `createimagefrompng()` from save_post hook (or equivalent hook)
- I think emoji are killing my WordPress site… How can I debug?
- Widgets not showing in my custom theme
- How do I list the_tags() into HTML data-attribute
- How do I translate this string – PHP syntax question
- Site Health : An active PHP session was detected
- Switching between custom templates in a post type of the admin menu
- Getting my head round WordPress filter
- Delete option value from array using update_option()
- Am I not understanding plugins?
- enqueue hover function
- Using Font Awesome as post thumbnail
- Can I change a variable in a content part while calling it?
- How To Change The Html of Products filtration sidebar in Woocommerce?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to set a custom path, for ajax image upload folder in admin?
- Insert all post IDs in new database table
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- How to display recent posts on home page with custom HTML
- Remove annoying WP Adminbar CSS