Last active
September 29, 2022 22:38
-
-
Save marklchaves/4ad3fbe848e07afe04963f7a77b612e6 to your computer and use it in GitHub Desktop.
Make a shortcode for a popup's name (not the title)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Ignore this first line when copying to your child theme's functions.php file. | |
/** | |
* Make a shortcode for a popup's name (not the title) | |
* | |
* Note: The popup's internal name is actually the CPT's title. | |
* The internal name is different from the popup's title. | |
* | |
* The popup's title is optional. If you enter a popup title, | |
* it displays as the heading of your popup (external title). | |
*/ | |
function popup_name_sc( ){ | |
if ( !function_exists('pum_get_popup_id') ) return; | |
$def_popup_id = pum_get_popup_id(); // Get the popup ID of the popup that's using this shortcode. | |
return get_the_title($def_popup_id); // Get the popup's post title. | |
} | |
add_shortcode( 'popup_name', 'popup_name_sc' ); | |
/** | |
* You can add the PHP code snippet to your child theme's functions.php file | |
* or with third-party plugins such as My Custom Functions and Code Snippets. | |
* | |
* Learn more: | |
* - https://docs.wppopupmaker.com/article/552-getting-started-with-custom-php | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment