• Resolved Poorang

    (@poorang)


    When I use get_the_title() to embed title in URL for sharing posts the HTML tags get into the URL too. How can I avoid that?
    I know I can get the secondary title by the_secondary_title(), but don’t know how to get primary title separately so I can concatenate them in the URL when I’m trying to share the posts with.

    https://www.ads-software.com/plugins/secondary-title/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author thaikolja

    (@thaikolja)

    Thanks for your message and excuse my late reply.

    Using Secondary Title’s “Auto show” function will activate a hook that modifies WP’s default get_the_title() and the_title() functions. If you’d like to use them without getting the secondary title, you’ll have to deactivate “Auto show”.

    The better solution would be using either the $post global or use get_post() if you’re not within the loop. Here are two examples:

    If you’re in the loop:

    global $post;
    echo $post->post_title;

    If not:

    $post_id = 1;
    $post = get_post($post_id);
    echo $post->post_title;

    I hope I could help.

    Thread Starter Poorang

    (@poorang)

    You definitely did. Thanks

    Plugin Author thaikolja

    (@thaikolja)

    Glad I could help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to get the primary title only’ is closed to new replies.