New to wordpress development, I am working on a plugin that retrieves data from a webservice.

I need an endpoint because the retrieved data also depends on the value of the page's metabox, so in effect the post endpoint variable url is to display a virtual child page.

The desired url would look like this:
I need the /(page)/ with /(endpoint)/ and /(variable)

The examples I've seen so far, all point to the use of specifically defined variables after the endpoint. Is it possible to have an endpoint with a query variable after?

  • Possible duplicate of Dynamic Endpoints – Howdy_McGee Feb 19 '16 at 15:51
  • The Dynamic Endpoints Question/Answer is an interesting approach, however my needs went beyond the use of a defined rewrite : add_rewrite_rule( '^cars/([^/]*)/?$'. Herein lies the advantage of using add_rewrite_endpoint( 'individuals', EP_PAGES ); – MediaFormat Feb 19 '16 at 19:39

Ok, so it might have been working all along, and I just hadn't flushed the rewrites!

function my_dept_listing_init() {
    //Easy flush
    if (isset($_GET['flush'])) {

    //endpoint onto which queries are made
    add_rewrite_endpoint( 'individuals', EP_PAGES ); 

    //This filter acts as a controller, inject into content
    add_filter('the_content', 'my_dept_listing_content_ctrl');
add_action('init', 'my_dept_listing_init');

function my_dept_listing_content_ctrl($content) {
    global $post;

    $getName = get_query_var('individuals');
    $post->post_title = $getName;

Hope this helps someone!

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.