• Hi,

    Is it possible to call a function to display a popup from within a template?

    Looking at the code looks like do_shortcode won’t do much but add a link to the template, wont include all the required JS and CSS.

    Is there some other function?

    Reason being we want a particular popup to show on every singe page and the section of the site to display the button which triggers the popup is not inside the post or page content.

    Sure could add the shorcode to each post and hide the outpout of the link with css but that becomes an extra step to adding content which is not preferred.

    Thanks.

    https://www.ads-software.com/plugins/popup-by-supsystic/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter andrew212

    (@andrew212)

    BTW, this solution does work however it’s not very dynamic, like if the popup id was to change well every post/page would have to be updated.

    //The "PopUp by Supsystic" will only include the required js and css files if the shortcode is found in the content.
    //As we want to display the newsletter popup button on every page, and it does not sit within the content (a theme option), we
    //add it to the content and just hide it so the  "PopUp by Supsystic" plugin picks it up and includes the necessary
    //fields on every page
    function point_add_popup_shortcode( $content ) {
      //check if the content already contains the shortcode
      $shortcode = '[supsystic-show-popup id=100]';
      if(strpos($content, $shortcode) === false) {
    	//add the shortcode to the content
    	$content .= '<!--' . $shortcode . '-->';
      }
      //return updated content
      return $content;
    }
    
    add_filter( 'content_save_pre', 'point_add_popup_shortcode', 10, 1 );

    Plugin Author supsystic

    (@supsysticcom)

    Hello.
    Please tell me – do you need to be able insert into your PHP code something like:
    <?php do_shortcode('[supsystic-show-popup id=100]')?>
    That will show PopUp on every page where such code in your template present?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Call a popup directly from template’ is closed to new replies.