[Resolved] php code is using ‘ and “

Home Forums Support php code is using ‘ and “

  • This topic has 8 replies, 3 voices, and was last updated 3 months ago by David.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1323950
    Karin

    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.

    #1324150
    Leo
    Staff
    Customer Support

    Hi 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?

    #1327320
    Karin

    Thanks 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.

    #1327565
    Leo
    Staff
    Customer Support

    I thought WP Subtitles used to work without editing the code but maybe things have changed since Gutenberg.

    #1328110
    Karin

    If you want WP subtitles to work with custom post types, it needs editing code as well. Unfortunately.

    #1328160
    Karin

    The 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?

    #1328250
    David
    Staff
    Customer Support

    Hi 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 )

    #1328298
    Karin

    Thanks for explaining. I’m still learning php…
    OK, it works.

    #1328309
    David
    Staff
    Customer Support
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.