How to print shortcode title & category from shortcode in wordpress

I want to add title & and category in shortcode
like this :

[custom_post_title title="Athletes" category_id="17669"]

I want to print the title of the shortcode
How can i do that Can anyone help me??


  • Add this code in functions.php file :

    $atts = shortcode_atts( array(
            'title' => null,
            'category_id' => null
        ), $atts);

    and after that you can use the given code for print the value where you want :

    echo $atts['title'];

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!