- This topic has 8 replies, 3 voices, and was last updated 3 years, 10 months ago by David.
-
AuthorPosts
-
June 11, 2020 at 9:49 am #1323950Karin
I want to add php code to content.php, related to another plugin (KIA subtitle plugin).
So, I looked at the file content.php (without any changes made to it) and I saw this code:do_action( 'generate_before_content' ); ?> <header class="entry-header"> <?php /** * generate_before_entry_title hook. * * @since 0.1 */ do_action( 'generate_before_entry_title' ); the_title( sprintf( '<h2 class="entry-title" itemprop="headline"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); /** * generate_after_entry_title hook. * * @since 0.1 * * @hooked generate_post_meta - 10 */ do_action( 'generate_after_entry_title' ); ?> </header><!-- .entry-header --> <?php
What makes me wonder it that in this code, I see sometimes ‘ and sometimes ”
Is this how it is supposed to be?I’m not a developer, but I hope that you can explain to me why sometimes “..” is used and sometimes ‘…’
This makes it easier for me to understand why adding additional code would work/not work.June 11, 2020 at 12:35 pm #1324150LeoStaffCustomer SupportHi there,
It’s pretty difficult to explain as it’s just syntax.
"
generally only used inside HTML.Make sure you are editing the file in the child theme and not the parent theme.
There should be plugins out there for subtitles without you having to edit the code no?
June 14, 2020 at 7:04 am #1327320KarinThanks for your answer. Yes, I’m going to edit the child theme.
And so far I couldn’t find a plugin that does not need to edit the code. The ones I found (KIA subtitle; WP subtitle) all need a code snippet to be added. But if you know a plugin that works without me having to edit the code, please let me know.June 14, 2020 at 9:00 am #1327565LeoStaffCustomer SupportI thought WP Subtitles used to work without editing the code but maybe things have changed since Gutenberg.
June 15, 2020 at 1:06 am #1328110KarinIf you want WP subtitles to work with custom post types, it needs editing code as well. Unfortunately.
June 15, 2020 at 2:01 am #1328160KarinThe developer of the KIA subtitle plugin gives the code snippet that I need to add to the child theme’s functions.php
That is:
function kia_add_subtitle_to_generatepress() { if ( function_exists( 'the_subtitle' ) ) { the_subtitle( '<h3 class="subtitle">', '</h3>' ); } } add_action( 'generate_after_entry_title', 'kia_add_subtitle_to_generatepress', 5 );
Is the way the theme is mentioned in this code snippet alright?
Or should this be: generatepress_child ?so, the last line, for example, needs to be
add_action( ‘generate_after_entry_title’, ‘kia_add_subtitle_to_generatepress_child’, 5 );How do I correctly refer to your theme in the code snippet?
June 15, 2020 at 3:23 am #1328250DavidStaffCustomer SupportHi there,
this
kia_add_subtitle_to_generatepress
is a function name, as long as it is unique then it could be named anything.this is a Hook name
generate_after_entry_title
and is correctly referring to a Hook in the GeneratePress theme.So the above code will work with GeneratePress ( and only GeneratePress )
June 15, 2020 at 3:55 am #1328298KarinThanks for explaining. I’m still learning php…
OK, it works.June 15, 2020 at 4:04 am #1328309DavidStaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.