Feed to Post's Effect on the Enclosure Link Option

The  Link to Enclosure option works differently when Feed to Post is enabled.

In the core plugin, it makes feed items link to the enclosure link, rather than the original article.

In Feed to Post, the enclosure link is added to the post content, at the beginning as a link.

Changing the Output Format of the Enclosure Link

The output of the enclosure link can be changed through the use of the filter below. The filter accepts 3 arguments, which are:

  • output
    • The current text/HTML output. By default, this will be an <a> tag, with its href link pointing to the enclosure, and its text set to the enclosure link.
  • enclosure
    •  The enclosure link URL for the current imported post is being shown on the site.
  • source
    • The ID of the feed source, from which the imported post was imported.

You can use these parameters in your filter function to set the output of the enclosure to whatever you want.

add_filter( 'wprss_ftp_enclosure_output', 'my_enclosure_output', 10, 3 );
function my_enclosure_output( $output, $enclosure, $source ) {
    return "<a href='$enclosure'>Click here to visit the enclosure resource.</a>";

The example below shows how all the parameters can be used:

add_filter( 'wprss_ftp_enclosure_output', 'my_enclosure_output', 10, 3 );
* This example changes the output to show a message followed by
* the default output (the <a> link to the enclosure) in bold format,
* for posts imported from the feed source with ID 34 only.
function my_enclosure_output( $output, $enclosure, $source ) {
    // If the feed source is not the feed source with ID 34
    // Return the default output
    if ( $source != 34 ) {
        return $output;
    // Change the enclosure output for feed source ID 34
    $new_output = "This post has an enclosure link: <strong>$output</strong>";
    return $new_output;

Changing the position of the enclosure link

By default, the enclosure link output is added to the post content,  before the post’s original content. If you wish to add the output after the content, use the below filter. The filter should return either “before” or “after“.

add_filter('wprss_ftp_enclosure_link_position', 'my_enclosure_position' );
function my_enclosure_position( $position ) {
    return 'after';

How do I add this to my site?

Follow the step-by-step instructions below to add this filter to your WordPress site.

  1. Copy the code you need from above.
  2. Go to your WordPress site's dashboard.
  3. Go to Plugins > Add New.
  4. Search for Code Snippets, then install and activate the plugin.
  5. Once installed and activated, go to Snippets in your dashboard menu.
  6. Click on Add New.
  7. Add a Title, which could be the title of this article.
  8. Paste the code you copied in step 1 to the Code section.
  9. Add a Description or Tags if you wish to do so. It is not required.
  10. Click on Save Changes and Activate to save the filter and activate it.
    1. Or click on Save Changes to save the filter and activate it later.
  11. Your action or filter is now stored and active on your site.

Still need help? Contact Us Contact Us