Wordpress Custom Plugin: Query String to Dynamic Url

Viewed 16

What I currently have developed:

http://wordpress.test/hashtag/result/?hashtag=twerk

What I want to achieve:

http://wordpress.test/hashtag/twerk

I have made a custom plugin which currently reads the 'hashtag' (query string) and displays it through my custom shortcode.

/result/ is a static page with the custom shortcode [woink_hashtag_result]. This currently works as intended.

Here is what I've currently produced.

function woinkResult()
{ 
    $return = '<p>' . get_query_var ('hashtag' ) . '</p>';

    // Output needs to be return
    return $return;
}

add_shortcode('woink_hashtag_result', 'woinkResult');

function pce_register_query_vars ( $vars ) {
        $vars[] = 'hashtag';
        return $vars;
    }
add_filter ( 'query_vars', 'pce_register_query_vars' );

How can I make the url prettier like: http://wordpress.test/hashtag/twerk ?

Thanks if you have made it this far.

0 Answers
Related