I'm trying to create a WordPress site that integrates with a very specific CRM in a remote server. The CRM holds a number of entries that should be displayed on the site, but if possible I'd like to avoid exporting and importing them into WordPress.

Instead, the WordPress site must be able to take in a custom permalink, such as:


And then retrieve the entry with ID 4573 from the remote server. Now, the retrieval itself is straightforward, but what about the custom permalink?

Ideally, WordPress would detect the 'property' keyword and then load a specific template for doing all the heavy lifting. With the ID, I can then perform a request and style all the resulting data into a page without ever needing a post type.

¿How can I create such a permalink structure and make WordPress detect that in a theme template?

2 Answers 2


I think your problem has several solutions. If you don't want to have one entry in WP database for each remote item, a possible solution could be to have a page with property slug and add a rewrite rule to get the ID number:

add_action( 'init', 'cyb_property_rewrite_rule' );
function cyb_property_rewrite_rule() {
    add_rewrite_rule( '^property/([0-9]{1,})/?$', 'index.php?pagename=$matches[1]&remote_ID=$matches[2]', 'top' );
//Add remote_ID to vars pool to be recognized by WordPress
add_filter('query_vars', 'cyb_add_query_vars');
function cyb_add_query_vars( $vars) {
    $vars[] = "remote_ID";
    return $vars;

Now, the ID of the item you want to retrieve is stored in remote_ID query var that you can get through get_query_var:

$item_ID = get_query_var('remote_ID');

You could create a page template for that page and, in the content, you cuould get the remote item:

Template Name: Property Page Template

<div id="content">
    $remote_item = cyb_get_the_property();


And in the cyb_get_the_property() you can fetch the data:

function cyb_get_the_property() {
    $item_ID = get_query_var('remote_ID');
    //Itegrate with the remote CMR API
    $item_data = '';
    return $item_data;
  • That did it. One thing to not is that I also had to use add_rewrite_tag in order to get the remote_ID variable, since WordPress purges all unrecognized query vars. Jan 5, 2015 at 12:04
  • You are right, remote_ID was not recognized by WordPress as a valid query var. I would use query_vars filter instead of add_rewrite_tag because we are adding a query var and not a rewrite tag. See edited answer.
    – cybmeta
    Jan 5, 2015 at 12:48

You can create a parent page with the slug "property" and all remote pages to be children of it with a slug being the same as their id. Does this make sense to you?

If you go with a solution of a custom post type with a slug "property", you might have problems with those numeric slugs, as I'm not quite sure if WordPress wouldn't try to fetch an entry with local id as the id of the remote page (which would be wrong).

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.