• I’ve created a shortcode in my themes function.php in order to get the title of the current post or page and display it on my site. I’m using it within a slider area and the problem is that sometimes the post titles are too long to fit nicely within the contained area. I’m wondering how can I modify my code to only return X number of characters of the post or page title. Here’s the snippet,

    // Add Shortcode
    function the_current_title() {
    return get_the_title();
    }
    add_shortcode( ‘the-title’, ‘the_current_title’ );

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to edit title length in custom shortcode’ is closed to new replies.