I am using the plugin "WP Attachments" to display attached media files on the post.

The plugin does not seem to have the ability to manually call the list in my template and I think the plugin is not really being supported anymore. I checked in the plugin code and I think the line below is the key.

add_filter('the_content', 'wpatt_content_filter');

My coding ability is limited, but I basically changed 'the_content' to 'the_attachedfiles' and in my functions.php I added:

function the_attachedfiles( $more_link_text = null, $strip_teaser = false ) {
     * Filters the post content.
     * @since 0.71
     * @param string $content Content of the current post.
    $content = apply_filters( 'the_attachedfiles', $content );
    $content = str_replace( ']]>', ']]>', $content );
    echo $content;

Then in my template I added the function I created as so:

<?php the_attachedfiles(); ?>

My question is, can I do this without changing plugin codes? If the plugin gets updated, I'd be forced to manually edit again. So would rather want an alternative.

Secondly, if I'm going to have to change the code in the plugin, then is this the best way and the line I added in the functions.php, I am guessing could also be better.

Any improvements would be appreciated.

1 Answer 1


Without looking into the plugin, it looks like you could first remove the default placement using:

remove_filter('the_content', 'wpatt_content_filter');

and then call the list function somewhere in your template like this:

echo wpatt_content_filter('');

(the remove_filter would be in functions.php or somewhere near the top of your template, ie before the_content() is called.)

  • That worked perfectly, thank you very much. It's solved both issues I had and "remove_filter" never knew I could do that. Cheers.
    – zavakz
    Apr 1, 2021 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.