Forums

[resolved] shortcode executed before content (3 posts)

  1. jakemc
    Member
    Posted 2 years ago #

    Hi.

    I have this in my functions.php:

    add_shortcode('ataglance', 'ataglance_function');
    function ataglance_function() {
    ?>
    <table>
    <!-- // generate table from xml file -->
    </table>
    <?php
    }

    And this in my page:

    test copy
    [ataglance]

    However, the page output (from the_content) is

    <table>...</table>
    test copy

    How can I make sure the code is executed in order?

    Thanks

  2. jakemc
    Member
    Posted 2 years ago #

    If anyone has the same problem, the answer is that the contents of the ataglance_function should be returned not echoed.

    Jake

  3. Héctor Cabrera
    Member
    Posted 2 years ago #

    Thanks Jake, this tip really came in handy!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags