Use feed source links for post imported with Feedzy RSS
Besides easily inserting content from any feed on your page, Feedzy RSS offers the option to import that content in the form of posts on your WordPress site.
You can read more about how to do that here.
But if you want to take things to the next level, you might want that your newly created posts link to the remote source where they're coming from, instead of your own site.
That can be easily achieved by adding the following code in the functions.php file of your active theme.
add_filter('post_link', function( $url, $id ){ $feed_url = get_post_meta( $id->ID, 'feedzy_item_url', true ); if ( !empty( $feed_url) ) $url = $feed_url; return $url; }, 99, 2);
If you want to use source links for custom posts also not only for default WordPress posts - use this code instead:
function change_feedzy_url( $url, $id ) { $feed_url = get_post_meta( $id->ID, 'feedzy_item_url', true ); if ( !empty( $feed_url) ) $url = $feed_url; return $url; } add_filter( 'post_type_link', 'change_feedzy_url', 99 , 2 ); add_filter( 'post_link', 'change_feedzy_url', 99 , 2 );
Note: Theme's updates will delete your custom code. To be sure that's not happening, you can use a child theme, and add the code in the functions.php file of your child theme.