1

How to get page title in to shortcode parameter's value? I have custom php script written which accepts parameters, I can send hard coded shotcodes in parameter as value but I have to send the page's title in parameter

2 Answers 2

1

Send post title in shortcode :

[myshortcode title='Web pages']

// shortcode

function shortcode_myshortcode($atts) {

$atts = shortcode_atts(
        array(
            'title' => 'no foo',            
        ), $atts);

return  $atts['title'];

}
add_shortcode('myshortcode', 'shortcode_myshortcode');
Sign up to request clarification or add additional context in comments.

Comments

0

Not sure that I understand your question, but to get the title of the current post use get_the_title(). You can use it within the shortcode function or when prepering the call for the custom php script you made.

https://developer.wordpress.org/reference/functions/get_the_title/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.