php - stop include from being placed at top of page in wordpress -


The issue using a shortcode, including a list just started with php, is that the wrapper's top , Where I'm placing it in the html editor: function (which I put in the function .php):

  function object list (include "(object 1. php "); } Add_shortcode ('get_my_objects', 'objectitist');   

html (WordPress HTML view):

  & lt; Div class = "listGenCont" & gt; & Lt; Div class = "objectList1" & gt; [Get_my_objects] & lt; / Div & gt; & Lt; / Div & gt;   

But the output ends:

  & lt; Ul class = "thingsathome" & gt; ** This included list is ** & lt; Div class = "listGenCont" & gt; & Lt; Div class = "actress list" & gt; ** This is where I need it ** & lt; / Div & gt; & Lt; / Div & gt;   

Why this happens and how to fix it

Then Check this code snippet ():

  function included_file ($ ATT) {// Check input and override the default file path NULL // if filepath was removed (shortcode_atts (array ('filepath' = & gt; 'NULL'), $ ATT); // check if the filepath was specified and if the file exists ($$ filepath! = 'NULL' & file_exists (TEMPLATEPATH. $ Filepath)) {// turnout output to capture script output on buffering (ob_start) ; // contains the file specified (TEMPLATEPATH. $ Filepath); // file output $ content variable and clean buffer $ content = ob_get_clean (); Return $ content; }} // Register the Shortcod handler add_shortcode ('Include', 'include_file');   

When you use plain, it is evaluated at the beginning of the WordPress request. Capturing of output buffer is used to prevent this example.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -