Add a custom menu item that supports wildcards

I am not very familiar with WordPress terminology yet, so this may be why my Google results come back empty but I guess this is a question that troubles a lot of developers with Drupal background that move to WordPress.

The short version:

“Is there a way to programmatically add a menu item like (where % are wildcards) and define what this page will return in my code?”

The extended version:

In Drupal there is a hook called hook_menu where you can define a menu path like the one mentioned above and a callback function that will take the wildcards as arguments.

What I’m trying to do here is simple: create a button on every post of the site; when this button is clicked in a specific post, it will do a simple GET request via AJAX to a menu item like: which will allow me to do some further processing of the specific post in the background.

I hope that the above makes sense. If this is not the way that things work in WordPress, please provide any resources as to how I should go about approaching the task at hand.

Read more here: Add a custom menu item that supports wildcards

Leave a Reply

Your email address will not be published. Required fields are marked *