WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to let my users submit links to my website something like reddit and digg. I added a meta_key 'syndication_permalink' which contains link to this post. How could I change the post permalink to link this custom link not to my page?

share|improve this question
can u plz help me with this wordpress.stackexchange.com/questions/152711/… thanx in advance – user3449454 Jul 5 '14 at 19:09

Filter post_link (or post_type_link for custom post types), fetch and validate the post meta value, then return that instead of the original link.

As a plugin:

 * Plugin Name: External Permalinks
 * Plugin URI:  http://wordpress.stackexchange.com/q/64285/73
 * Description: Uses the value of post meta field <code>syndication_permalink</code> as permalink if available.
 * Version:     2012.11.13
 * Author:      Thomas Scholz
 * Author URI:  http://toscho.de
 * Licence:     MIT
 * License URI: http://opensource.org/licenses/MIT

add_filter( 'post_link', 'wpse_64285_external_permalink', 10, 2 );

 * Parse post link and replace it with meta value.
 * @wp-hook post_link
 * @param   string $link
 * @param   object $post
 * @return  string
function wpse_64285_external_permalink( $link, $post )
    $meta = get_post_meta( $post->ID, 'syndication_permalink', TRUE );
    $url  = esc_url( filter_var( $meta, FILTER_VALIDATE_URL ) );

    return $url ? $url : $link;

Sample input:

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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