Skip to content

Instantly share code, notes, and snippets.

@stefan-cotitosu
Last active July 12, 2022 09:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefan-cotitosu/aba95356e3292124edd964206667442e to your computer and use it in GitHub Desktop.
Save stefan-cotitosu/aba95356e3292124edd964206667442e to your computer and use it in GitHub Desktop.
Feedzy - link the title of imported posts to the original article
<?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