This topic has 3 replies, 2 voices, and was last updated 6 years by Kieran_SQ.

  • Author
  • #202563
     stefanlim
    Participant

    Hi there!

    I would like to check if there’s a way to display post title, author and date in a post, as text (or part of the article). Is there a shortcode on this or something?

    Thanks!

    #202575
     Kieran_SQ
    Moderator

    Hi,

    I couldn’t find anything immediately through a search so I wrote this custom code for you that I will release later in a plugin. For now you can copy this code (from the ticket and not the email) and add it to your functions.php file

    COPY CODE
    function piqt_replace_tags($text) {
        
        // Get post information
        
        $pi_title = get_the_title();
        $pi_author = get_the_author();
        $pi_date = get_the_date();
        
        // Text to replace with post information
        
        $text = str_replace('{the_title}', $pi_title, $text);
        $text = str_replace('{the_author}', $pi_author, $text);
        $text = str_replace('{the_date}', $pi_date, $text);
        return $text;
    }
    
    // Enable within the content
    
    add_filter('the_content', 'piqt_replace_tags');
    
    // Enable within the menu
    
    add_filter('walker_nav_menu_start_el', 'piqt_replace_tags');

    You can use the following tags in your content or menus to generate the post title, author and date.

    COPY CODE
    {the_title}
    {the_author}
    {the_date}

    Thanks,

    Kieran.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #202577
     stefanlim
    Participant

    Thanks a ton Kieran! This works perfectly. Appreciate it!

    #202578
     Kieran_SQ
    Moderator

    Hi,

    No worries, happy to help 🙂 I’ll mark this ticket as resolved for now. If you need help with anything else please feel free to open a new ticket any time.

    If you have a spare moment please consider leaving the support you have received / KLEO a review on ThemeForest. Every review really does help me.

    https://themeforest.net/item/kleo-pro-community-focused-multipurpose-buddypress-theme/reviews/6776630

    All the best,

    Kieran

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

Viewing 4 posts - 1 through 4 (of 4 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?