[Support request] How to Add Subtitle Below the title of the Blog Post?

Home Forums Support [Support request] How to Add Subtitle Below the title of the Blog Post?

Home Forums Support How to Add Subtitle Below the title of the Blog Post?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1102318
    Prakhar

    Actually I wanna add subtitle Below the title. Like My title be black and bold and subtitle is small than this and light. Please help me.

    #1102333
    David
    Staff
    Customer Support

    Hi there,

    i explain how to in this topic:

    https://generatepress.com/forums/topic/2-things-i-need-to-do-it-with-gp-theme-after-bought-it/#post-852326

    You only need to follow steps in point 1.

    #1102782
    Prakhar

    I want to add this manually. I mean I don’t want any plugin for this. I wanna do with the help of code. Please Help ASAP

    #1103055
    David
    Staff
    Customer Support

    You would need to use WordPress Custom Fields:
    https://wordpress.org/support/article/custom-fields/

    And Hook this code into site, as per the topic i linked to:

    <?php
    // Get custom field value
    $subtitle = get_post_meta( get_the_ID(), 'your-custom-field', true );
    // Display $subtitle if not empty
    if ( ! empty( $subtitle ) ) {
        echo '<p class="custom-subtitle">' . $content . '</p>';
    } 
    ?>

    Change the your-custom-field slug to whatever you named your custom field.

    #1967446
    Markus

    Hi David,

    I try to use the last solution (subtitles) and I use GeneratePress Child: functions.php. Is this the right place where I should insert the code?
    It didn’t worked yet.

    Kind Regards,
    Markus

    #1967592
    Ying
    Staff
    Customer Support

    Hi Markus,

    Do you want to add the subtitle before the entry title in each single post?

    If so, try add this code in a hook element, change the your-custom-field to the slug of your custom field.

    <?php
    // Get custom field value
    $subtitle = get_post_meta( get_the_ID(), 'your-custom-field', true );
    // Display $subtitle if not empty
    if ( ! empty( $subtitle ) ) {
        echo '<p class="custom-subtitle">' . $subtitle. '</p>';
    } 
    ?>

    Tick the Execute PHP box, choose generate_before_entry_title as the hook, choose post > all posts as location.

    Please refer to the screenshot below:
    https://www.screencast.com/t/R3qY61cW0gv

    If you want it to be at other spot on the site, here’s the visual hook guide:
    https://docs.generatepress.com/article/hooks-visual-guide/

    #1995191
    Markus

    Hi Ying,

    Okay, that explanation helped. Thank you very much!!! Awesome.

    Is there a possibility to adapt form and font size of this subtitle?

    Kind Regards,
    Markus

    #1995202
    Ying
    Staff
    Customer Support

    Is there a possibility to adapt form and font size of this subtitle?

    You can use CSS to style the text. 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.