- This topic has 7 replies, 2 voices, and was last updated 4 years, 4 months ago by
Ying.
-
AuthorPosts
-
December 12, 2019 at 8:26 am #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.
December 12, 2019 at 8:49 am #1102333David
StaffCustomer SupportHi there,
i explain how to in this topic:
You only need to follow steps in point 1.
December 12, 2019 at 8:50 pm #1102782Prakhar
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
December 13, 2019 at 4:00 am #1103055David
StaffCustomer SupportYou 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-fieldslug to whatever you named your custom field.October 18, 2021 at 8:22 am #1967446Markus
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,
MarkusOctober 18, 2021 at 11:01 am #1967592Ying
StaffCustomer SupportHi 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-fieldto 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_titleas the hook, choosepost > all postsas location.Please refer to the screenshot below:
https://www.screencast.com/t/R3qY61cW0gvIf 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/November 7, 2021 at 3:04 pm #1995191Markus
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,
MarkusNovember 7, 2021 at 3:24 pm #1995202Ying
StaffCustomer SupportIs there a possibility to adapt form and font size of this subtitle?
You can use CSS to style the text. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.