Title: plugin posting wrong URL in facebook
Last modified: June 5, 2017

---

# plugin posting wrong URL in facebook

 *  [cisnerosebastian](https://wordpress.org/support/users/cisnerosebastian/)
 * (@cisnerosebastian)
 * [8 years, 11 months ago](https://wordpress.org/support/topic/plugin-posting-wrong-url-in-facebook/)
 * I’m sure this has to be with some custom programming I’m doing on the website,
   but the plugin should be able to get the correct URL.
 * I have a custom posttype “a” and a custom posttype “b”. One of the metadata of
   the custom posttype “b” is to select 1 postype “a” (like to choose a category
   or something). Anyway,once you publish the posttype “b” it modifyies it url to
   have in it, posttype “a” something like : [http://www.mywebsite.com/a/b](http://www.mywebsite.com/a/b),
   To do this I’m using the filter “post_type_link” . All works perfect, and wordpress
   is aware of this URL update, all plugins and wordpress itself, when you ask for
   the permalink of post id 999, it gets the [http://www.mywebsite.com/a/b](http://www.mywebsite.com/a/b)
   as expected. But when using this plugin, the URL posted on facebook is wrong,
   like it isn’t aware of my url update.
 * anyway I can fix this?
 * my code below so you can check it.
 *     ```
       global $wp_rewrite;
       $wp_rewrite->add_rewrite_tag( '%_data_salida%', '([^&]+)', '?meta=' );
       function extra_post_link( $permalink, $post, $leavename ) {
           if ( stripos( $permalink, '%_data_salida%' ) == false ) {
               return $permalink;
           }
           if ( is_object( $post ) && $post->post_type == 'reportes' ) {
               $_selected_post_slug = '';
               $_selected_post_id = get_post_meta( $post->ID, '_data_salida', true );
   
               if ( $_selected_post_id )
                   $_selected_post_slug = get_page_uri( $_selected_post_id );
   
               if ( ! $_selected_post_slug )
                   return str_replace( '%_data_salida%', '', $permalink );
   
               return str_replace( '%_data_salida%', "$_selected_post_slug/", $permalink );
           }
           return $permalink;
       }
       add_filter( 'post_type_link', 'extra_post_link', 10, 3 );
       ```
   
    -  This topic was modified 8 years, 11 months ago by [cisnerosebastian](https://wordpress.org/support/users/cisnerosebastian/).
    -  This topic was modified 8 years, 11 months ago by [cisnerosebastian](https://wordpress.org/support/users/cisnerosebastian/).
    -  This topic was modified 8 years, 11 months ago by [cisnerosebastian](https://wordpress.org/support/users/cisnerosebastian/).

The topic ‘plugin posting wrong URL in facebook’ is closed to new replies.

 * ![](https://ps.w.org/facebook-auto-publish/assets/icon-128x128.png?rev=2124304)
 * [WP2Social Auto Publish](https://wordpress.org/plugins/facebook-auto-publish/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/facebook-auto-publish/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/facebook-auto-publish/)
 * [Active Topics](https://wordpress.org/support/plugin/facebook-auto-publish/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/facebook-auto-publish/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/facebook-auto-publish/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [cisnerosebastian](https://wordpress.org/support/users/cisnerosebastian/)
 * Last activity: [8 years, 11 months ago](https://wordpress.org/support/topic/plugin-posting-wrong-url-in-facebook/)
 * Status: not resolved