Last active
July 12, 2022 09:29
-
-
Save stefan-cotitosu/aba95356e3292124edd964206667442e to your computer and use it in GitHub Desktop.
Feedzy - link the title of imported posts to the original article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Feedzy posts - link the title to the original article | |
* Description: Link the title of posts imported by Feedzy to the original article | |
* Version: 1.0 | |
* Author: Themeisle | |
* Author URI: https://themeisle.com | |
*/ | |
/** | |
* Filters the permalink for a post and custom post type. | |
* | |
* @param string $url Post link. | |
* @param object $post Post Object. | |
* @return string | |
*/ | |
function feedzy_rss_filter_post_link( $url, $post ) { | |
if ( is_admin() ) { | |
return $url; | |
} | |
$current_post_meta = get_post_meta( $post->ID, 'feedzy_item_url', true ); | |
if ( ! empty( $current_post_meta ) ) { | |
return $current_post_meta; | |
} | |
return $url; | |
} | |
add_filter( 'post_type_link', 'feedzy_rss_filter_post_link', 99, 2 ); | |
add_filter( 'post_link', 'feedzy_rss_filter_post_link', 99, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment