Search code examples
phpwordpressdivi-theme

WordPress Divi shortcode adding


WordPress Divi Theme shortcode adding problem

My Divi version is 3.20.1. I am trying to add my own custom shortcode in the website. However, when I add this shortcode, the elements displayed using this shortcode appear both in the "Edit page" area top section besides the main page.

add_shortcode( "Btx_Show_Testimonial_Main_Page", 'lantry_btx_fun_Main_Page_Show_Testimonial');
function lantry_btx_fun_Main_Page_Show_Testimonial(){
     include_once LANTRY_BITECHX_SHORTCODE_DIR_PATH."views/Main_Page_testimonial_show.php"; 
}

My question is, how can I remove this from the "Edit page" section ??

I provided some screenshot.

Divi module Image Option Select Show top of the post page


When I remove Divi this problem will be solved. But I need to use Divi.


Solution

  • You can check if a adminuser is logged in and if not execute your function hope this helps but now you have to always log out or use incognito mode to see if its there:

    add_shortcode( "Btx_Show_Testimonial_Main_Page", 'lantry_btx_fun_Main_Page_Show_Testimonial');
    function lantry_btx_fun_Main_Page_Show_Testimonial(){
         if (current_user_can( 'update_core' )) {
              return;
          }
         include_once LANTRY_BITECHX_SHORTCODE_DIR_PATH."views/Main_Page_testimonial_show.php"; 
    }