Title: Filter permalink
Last modified: January 30, 2018

---

# Filter permalink

 *  Resolved [Etienne](https://wordpress.org/support/users/epipo/)
 * (@epipo)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filter-permalink/)
 * Hello,
 * I was just wondering if it would be possible to filter the permalink for some
   pages. I am using the shortcode and I need the permalink to be different than
   the current page/post. I have noticed a `scriptlesssocialsharing_get_permalink`
   filter but I am not sure how to use it.
 * I want to do something like this:
 *     ```
       $postID = (is_page(18712)) ? get_query_var( 'pid', 12752 ) : get_the_ID();
       $permalink = get_the_permalink( $postID );
       $attributes['permalink'] = $permalink;
       apply_filters('scriptlesssocialsharing_get_permalink', 'sep_filter_sharing_permalink');
       ```
   
 * Could you help me?
    Thanks!
    -  This topic was modified 8 years, 4 months ago by [Etienne](https://wordpress.org/support/users/epipo/).
    -  This topic was modified 8 years, 4 months ago by [Etienne](https://wordpress.org/support/users/epipo/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Robin Cornett](https://wordpress.org/support/users/littlerchicken/)
 * (@littlerchicken)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filter-permalink/#post-9919660)
 * I believe this will work, but you’ll want to double/triple check it (it worked
   for me locally, at least). I’ve revised your code to this:
 *     ```
       add_filter( 'scriptlesssocialsharing_get_permalink', 'sep_filter_sharing_permalink', 20, 3 );
       /**
        * Modify the Scriptless Social Sharing permalink on page 18712.
        * @param $permalink
        * @param $button_name
        * @param $attributes
        *
        * @return false|string
        */
       function sep_filter_sharing_permalink( $permalink, $button_name, $attributes ) {
       	if ( ! is_page( 18712 ) ) {
       		return $permalink;
       	}
       	$post_id = get_query_var( 'pid', 12752 );
   
       	return get_the_permalink( $post_id );
       }
       ```
   
 * That should only modify the link on page 18712 and otherwise return the standard
   permalink. The function does not account for what to do if the post ID 12752 
   does not exist, so you may need to adjust it more.
 * Please practice safe coding, make sure you have your files backed up, etc. Hope
   this helps get you started.
 *  Thread Starter [Etienne](https://wordpress.org/support/users/epipo/)
 * (@epipo)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/filter-permalink/#post-9943980)
 * Works like a charm, thanks a lot :)!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Filter permalink’ is closed to new replies.

 * ![](https://ps.w.org/scriptless-social-sharing/assets/icon-256x256.jpg?rev=1361689)
 * [Scriptless Social Sharing](https://wordpress.org/plugins/scriptless-social-sharing/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/scriptless-social-sharing/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/scriptless-social-sharing/)
 * [Active Topics](https://wordpress.org/support/plugin/scriptless-social-sharing/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/scriptless-social-sharing/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/scriptless-social-sharing/reviews/)

## Tags

 * [permalink](https://wordpress.org/support/topic-tag/permalink/)

 * 2 replies
 * 2 participants
 * Last reply from: [Etienne](https://wordpress.org/support/users/epipo/)
 * Last activity: [8 years, 4 months ago](https://wordpress.org/support/topic/filter-permalink/#post-9943980)
 * Status: resolved