2

The short version:

Any link from Facebook to a page stops evaluating at the "hardcoded page" in the wordpress press install, ignoring the remaining parts of the URL. It doesn't allow the shortcode I wrote, that autogenerates the content on a page for any realestate listing in an external table, to evaluate.

The Long Version

I've created a wordpress plugin that displays the content (real estate listings) from an external database, which works as intended. I use a shortcode to show any of the individual listings on a single page ie: http://www.lbjrealestate.com/property/Horseshoe-Bay/Horseshoe-Bay-P/1104-unit-3-The-Cape/119526/

This all works spectacularly, until you try to post a link to the property from facebook. FB evaluates the above link only up till the page that exists in wordpress (http://www.lbjrealestate.com/property/) which then renders the title to be "No properties match that mls number", and as you might expect, this is a problem. (aside: google+ handles the link just fine)

Other potentially relevant info: I'm not using a custom post type, rather, I've created a page that has a shortcode on it.

Here is the initialization portion of the plugin, what am I missing?

class property_search {
        static $add_script;

        static function init() {
            add_action( 'wp_loaded', array(__CLASS__, 'ps_flush_rules' ));
            add_filter( 'rewrite_rules_array', array(__CLASS__, 'ps_insert_rewrite_rules' ));
            add_filter( 'query_vars', array(__CLASS__, 'ps_insert_query_vars' ));

            add_filter( 'the_title', 'do_shortcode' );
            add_filter( 'wp_title', 'do_shortcode' );

            add_shortcode('show_property', array(__CLASS__, 'property_shortcode'));
            add_shortcode('property_title', array(__CLASS__, 'property_title_shortcode'));
        }

        static function ps_flush_rules() {
            $rules = get_option( 'rewrite_rules' );

            if ( ! isset( $rules['(property)/(.+)$'] ) || ! isset( $rules['(properties)/(.+)$'] ) ) {
                global $wp_rewrite;
                $wp_rewrite->flush_rules();
            }
        }

        static function ps_insert_rewrite_rules( $rules ) {
            $newrules = array();
            $newrules['(property)/(.+)$'] = 'index.php?pagename=$matches[1]&property=$matches[2]';
            $newrules['(properties)/(.+)$'] = 'index.php?pagename=$matches[1]&geolocation=$matches[2]';
            return $newrules + $rules;
        }

        static function ps_insert_query_vars( $vars ) {
            array_push($vars, 'property');
            array_push($vars, 'geolocation');
            return $vars;
        }

        ...

}

1 Answer 1

2

The problem is that the canonical url on all of those pages is http://www.lbjrealestate.com/property/. You either need to generate a custom canonical link for your pages, or provide an og:url tag for Facebook to read. Enter your url in the debugger to see what Facebook sees.

1
  • I removed the canonical url from the header and everything works as expected. Thanks!
    – miah
    Jul 31, 2012 at 3:07

Your Answer

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

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