I have a WordPress marketing site (www.example.com) and a backend app site (app.example.com). What I am trying to do is this: if some body goes to the URL:


I want to create a page that has mostly generic content and one iframe with src


Now I have 2 problems:

  1. Can a page have dynamic URL? If i try to set the URL to www.example.com/profile/*/ it becomes www.example.com/profile/
  2. If I do get the page to work, how to pass profileId to the iframe src?

Can somebody please direct me to a plugin/solution?

2 Answers 2


Step 1:

Create a page with slug 'profile' in your WordPress Dashboard.

Step 2

Use this function to register profileId var.

add_filter('query_vars', 'wp233_query_vars');
function wp233_query_vars( $query_vars ){
    $query_vars[] = 'profileId';
    return $query_vars;

And add a rewrite rule to wordpress like this:

add_action( 'init', 'wp233_add_rewrite_rules' );
function wp233_add_rewrite_rules() {



Step 3

Now you can access the query var like this:


Now you should be able to extract the profileId by hooking in suitable action


add_action( 'template_redirect', 'wp233_get_profile_id' );
function wp233_get_profile_id() {

   $profile_id = get_query_var( 'profileId' );
   if ( $profile_id ) {

    // do some magic work. you now captured the profile id
    // which was passed to url.com/profile/{ID}/ -> here.



This shouldn't be too difficult. First you have to get the <<profileID>> part of the current page/post. How to get it, depends on what it is and where in your template you are calling it. If, for instance, "profile" is a custom post type, then <<profileID>> is the slug of the post, which you could retrieve like this, presumably in single.php:

$profileID = get_post_field( 'post_name', get_post());

The rest is straightforward PHP:

echo '<iframe src="my.example.com/profile/' . $profileID '/></iframe>';

Now you have your page with the iframe and you want to display it without the slug. The answer to that is here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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