0

I want a create a simple HTML page (not Wordpress Page) programmatically by using the permalink structure of another already existing post.

E.g. Already existing post is www.example.com/this-is-example-post

I want to create 3 more pages viz.

www.example.com/this-is-example-post/index1
www.example.com/this-is-example-postindex2
www.example.com/this-is-example-post/index3

These URLs need not be real pages. I just need three different pages to store different Facebook meta. I'm building a plugin. Please guide. How can I achieve it?

Am I thinking twisted? I'm going crazy thinking about it. :( Please help.

-------------EDIT---------------

After working on suggestions from Rahil, here's where I'm now

<?php 
add_action( 'init', 'xx_add_endpoint' );

function xx_add_endpoint()
{
    add_rewrite_endpoint( 'index', EP_PERMALINK );
}

add_action( 'template_redirect', 'xx_render_endpoint' );

function xx_render_endpoint()
{
    if ( ! is_singular() or ! get_query_var( 'index' ) )
    {
        return;
    }

    // Do somthing here
    exit;
}


add_filter( 'request', 'xx_set_endpoint_var' );

function xx_set_endpoint_var( $vars )
{
    isset( $vars['index'] ) and $vars['index'] = true;
    return $vars;
}

?>

But I'm trying to understand how I can pass variables to this request e.g. www.example.com/this-is-example-post/index/20/1, www.example.com/this-is-example-post/index/20/2, www.example.com/this-is-example-post/index/20/3 and so on.

p.s. I intend to pass two values viz. /index/a/b where a,b are the two values to be sent and handled under xx_render_endpoint function.

Please guide.

  • you can start with searching for add_rewrite_endpoint – Milo Jun 7 '14 at 14:52
  • Hi @Milo, I've made changes in the question to add my progress with add_rewrite_endpoint. Can you kindly guide me further. I'm stuck. I'm new to php and WP. :( – LittleLebowski Jun 7 '14 at 15:04

Your Answer

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

Browse other questions tagged or ask your own question.