variable endpoints for webservice

by DjungleDev   Last Updated February 18, 2016 09:03 AM

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

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?

Answers 1

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!

February 19, 2016 15:49 PM

Related Questions

Multiple endpoints in one URL

Updated April 08, 2016 09:03 AM