Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm using the latest Wordpress release with the default theme.

I have a function similar to this which is included and called from within a page (using exec-PHP).

<?php function myFunc($value) {
        while () // some condition {
             echo $value;
        }
 ?>
 <?php myFunc('val'); ?>

the output of the echo function is appearing at the bottom of the page instead of appearing within the correct page content section.

How can I fix this?

share|improve this question
add comment

1 Answer

Create a shortcode and return the content instead of echoing it out so in your functions.php file add:

function myFunc($atts,$content = null) {
    while (ture) {
       return $content;
    }
    return '';
}

add_shortcode('myfunc','myFunc');

and in your page's content instead of using exec-PHP just call your new shortcode:

[myfunc]val[/myfunc]
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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