• Greetings,

    I’ve inserted the following PHP code in a snippet:
    $StartDate = strtotime(‘2016-05-10’); //Start date from which we begin count
    $CurDate = date(“Y-m-d”); //Current date.
    $NextDate = date(“Y-m-d”, strtotime(“+2 week”, $StartDate)); //Next date = +2 week from start date
    while ($CurDate > $NextDate ) {
    $NextDate = date(“Y-m-d”, strtotime(“+2 week”, strtotime($NextDate)));
    }
    echo date(“Y-m-d”, strtotime($NextDate)), “\n”;

    I’ve inserted the correspondent shortcode in the HTML editor of a page and the code is executed. The problem is that the result always appears on the top of the page (instead of the place where the shortcode is placed).

    How can I solve this situation and get the PHP code result in the proper place?

    Thanks in advance.

    https://wordpress.org/plugins/insert-php-code-snippet/

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’m having the same issue. Probably has something to do with the version of PHP running on the server. It works fine on PHP 5.5 but not 5.6.

    i had this problem on the search results page, doing a test solved this.
    if !( is_search() ) {put the code you want}

    But it’s a bit weird

    Enabling PHP output_buffering directive may fix this.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘PHP Snippet always appears on top of page’ is closed to new replies.