Plugin content always on top of post Wordpress, PHP -


im trying make wordpress plugin. done , working, except 1 thing.

i have added shortcode plugin. no matter in content call shortcode , contents gets on top of post, instead of placed tag.

the code outputs something:

public static function showincomingsearches(){  global $id; $arsearches = self::getarobj(array('wp_post_id' => $id));  ob_start(); if(!empty($arsearches)){ $str = '<ul>' . php_eol;              foreach($arsearches $osearch){         $str .= '<li>'.htmlspecialchars($osearch->searchterm).'</li>' . php_eol;     }  $str .= '</ul>';  if(!empty($arsearches))     echo $str; } else {     echo ' '; }  return ob_get_clean(); 

}

and shortcode functionality:

add_shortcode('show_incoming_searches', 'checkreferrer'); function checkreferrer(){     incomingsearches::checkreferrer();       echo incomingsearches::showincomingsearches(); } 

could explain me why it's on top of content ? have no clue :(

thanks!

your shortcode code needs return content, not echo it.

function checkreferrer(){     incomingsearches::checkreferrer();       return incomingsearches::showincomingsearches(); } 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -