• Hi,

    Am working on $content to append some content from function. So I have added like this,

    function one($content){
    return $content.functionname();
    }
    
    add_filter('the_content','one');
    
    functionname(){echo 'hello';}

    Am getting output as
    hello then only the content but actually it should be content then hello.

    So functions take more precedence over the $content. Could you please give some solution to display like content and then function operations.

Viewing 1 replies (of 1 total)
  • You should not be echoing the value in functioname() because that’s outputting the value before anything is done with it. It should look like this:

    function functionname () {
        return 'hello';
    }

    That will give you what you’re after.

    Also, the priority when you use add_filter() is an integer, not a string, so you’d need to pass it 1, not one, to make it work first up.

Viewing 1 replies (of 1 total)

The topic ‘Function takes more precedence over $content’ is closed to new replies.