How to open a popup with a link

To open a poup with a link, in the Custom jQuery of the popup enter :
var notview=1;
Now you have different choice to open the popup :

– directly in the link, enter your link like that :
<a href="javascript:void()" onclick='jQuery("#popup").modal({open:true,closeClass:"popoup-front-close",overlayClose:true})'>Open Pop Up</a>
– with a class, for example all links with the “openPopUp” class, enter
this in the Custom jQuery :
jQuery('a.openPopUp').click(function(){
jQuery("#popup").modal({open:true,closeClass:"popoup-front-close",overlayClose:
true});

WARNING WITH NEW VERSION OF WORDPRESS

The new version of wordpress can no longer change the url in the editor, now, it's betterĀ to use a shortcode, here for example a code that you can add in the functions.php file of your theme


function ahref_func($atts, $content=null) {
extract( shortcode_atts( array(
'href' => '',
'onclick' => '',
'rel' => '',
'title' => '',
'name' => ''
), $atts ));
$onclick = "{$onclick}";
if($onclick){
$onclickcode = " onclick=\"".$onclick."\"";
}
$rel = "{$rel}";
if($rel){
$relcode = " rel=\"".$rel."\"";
}
$title = "{$title}";
if($title){
$titlecode = " title=\"".$title."\"";
}
$name = "{$name}";
if($name){
$namecode = " name=\"".$name."\"";
}
return "<a href="\"{$href}\"".$onclickcode.$relcode.$titlecode.$namecode."">" . $content . "</a>";
}
add_shortcode('a', 'ahref_func' );

Now you can use this shortcode in your post or page

[a href="javascript:void()" onclick="jQuery('#popup').modal({open:true,closeClass:'popoup-front-close',overlayClose:true})"]Open the popup with a link[/a]






Comments are closed.