$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>A number appears inside a div called wpb_wrapper, when I use a custom shortcode|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

A number appears inside a div called wpb_wrapper, when I use a custom shortcode

matteradmin8PV0评论

the page automatically display a number inside a div called wpb_wrapper, when I use a custom shortcode. but its nowhere in my function. When I delete the shortcode the number goes away.

<div class="wpb_text_column wpb_content_element " >
    <div class="wpb_wrapper">
        1

    </div>
</div>

Any clues?

Is a custom Shortcode to display a grid of post, it contains PHP code, HTML tags and CSS.

function millennium_grid(){
   return include("mg-custom-grid.php");

add_shortcode('millennium', 'millennium_grid');

the page automatically display a number inside a div called wpb_wrapper, when I use a custom shortcode. but its nowhere in my function. When I delete the shortcode the number goes away.

<div class="wpb_text_column wpb_content_element " >
    <div class="wpb_wrapper">
        1

    </div>
</div>

Any clues?

Is a custom Shortcode to display a grid of post, it contains PHP code, HTML tags and CSS.

function millennium_grid(){
   return include("mg-custom-grid.php");

add_shortcode('millennium', 'millennium_grid');
Share Improve this question edited Nov 21, 2018 at 15:28 Trauko asked Nov 21, 2018 at 15:17 TraukoTrauko 251 silver badge6 bronze badges 1
  • 1 Which shortcode / plugin you are referring to? Can you be more specific? – middlelady Commented Nov 21, 2018 at 15:23
Add a comment  | 

1 Answer 1

Reset to default 1

You can't return an include like that. A successful include() itself returns 1, and since you're returning the return value of include, your shortcode is displaying "1".

Handling Returns: include returns FALSE on failure and raises a warning. Successful includes, unless overridden by the included file, return 1.

— http://php/manual/en/function.include.php

If you want to output a template or similar file from shortcode, you need to capture it with output buffering:

function millennium_grid() {
    ob_start();

    include 'mg-custom-grid.php';

    return ob_get_clean();
}
add_shortcode( 'millennium', 'millennium_grid' );
Post a comment

comment list (0)

  1. No comments so far