• Resolved gorshan44

    (@gorshan44)


    Hi, great job with the plugin. Only one thing, is it possible to use the page title as a variable in the title and/or description of the popups. For example if I have a page called “Cool shoes”, can I have a popup triggered with title “If you like Cool shoes click here”?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Predrag – WPMU DEV Support

    (@wpmudev-support1)

    Hi @gorshan44,

    I’m afraid that there’s no such option within Hustle, but what you can do is register a new shortcode that will call page title and use that in your Popup content. Shortcode in titles are not support so it would need to be added into content directly, but you can use CSS or set the text as heading type.

    What you would need to do first is create a new .php file inside wp-content/mu-plugins/ folder (if you don’t have mu-plugins folder simply create your own).
    You can set whatever name for that .php file and paste this code inside it:

    <?php
    // Add Shortcode for Page Title
    function page_title_shortcode() {
    
    	$title = get_the_title();
    	return $title;
    
    }
    add_shortcode( 'my_page_title', 'page_title_shortcode' );

    Save the file and you’re able to add title now by using [my_page_title] shortcode.

    Here’s how it would look in your popup content backend:

    View post on imgur.com

    And this is how it’s being displayed on frontend:

    View post on imgur.com

    Hope this does the trick for you.

    Cheers,
    Predrag

    Thread Starter gorshan44

    (@gorshan44)

    BOOM! You’re an absolute star Predrag, I just quickly tested in dev and it worked out first try. Thank you so much for providing the code too!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using page title as variable’ is closed to new replies.