Skip to content
Advertisement

How to rewrite an echo function to a return value for a WordPress theme

I am new to PHP and I am glad that I have written the following function (which works as it should) on my own so far:

JavaScript

But now I definitly need your help… As you can see I want to use this function in a shortcode. Currently it displays first on my page, and Google says, this is because I am echoing the content and I would need to give a return value.

How do I do this?? Is it just replacing the word “echo” with the word “return” ? I have no idea…

Advertisement

Answer

I have condensed a few statements together for readability but here’s what that would look like:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement