Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement