[Resolved] File edits and Child Theme

Home Forums Support [Resolved] File edits and Child Theme

Home Forums Support File edits and Child Theme

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1500722
    Aleksey

    Hi!

    I’ve editied post-meta.php here “generatepress\inc\structure” to add author box inside <footer> tag. To save this edit from deleting during further updates I’ve created the same folders in the child theme and copied my new post-meta.php there. But unfortunately, edits don’t show on the website.

    How can I make this changes work with child theme?

    #1500733
    Elvin
    Staff
    Customer Support

    Hi,

    I believe this can be done w/ just filters and hooks instead of creating a post-meta.php.

    Something like this:

    add_filter('generate_before_footer_content', function(){
        //your author box code here
    });

    Simply add this code to your child theme’s functions.php.

    If you want to place it somewhere else, you can replace the hook w/ any hooks found here:
    https://docs.generatepress.com/article/hooks-visual-guide/

    #1500850
    Aleksey

    Thanks for a quick reply. Somehow this code:

    
    add_filter('generate_after_entry_content', function() {
      <strong><div class="author-box"></strong>
    	<?php global $post; ?>
     
    	<div class="avatar"><?php echo get_avatar ( get_the_author_meta( 'ID' )); ?></div>
     
            <div class="author-title" itemprop="author" itemscope itemtype="http://schema.org/Person">
    	<span itemprop="name"><?php printf( get_the_author_meta( 'display_name') );?></span>
    </div>
    	
    				<div class="author-summary">
    	
            <p class="author-description"><?php echo nl2br( get_the_author_meta( 'description' ), null ); ?></p>
        </div>
    </div>
    });

    doesn’t want to work.

    syntax error, unexpected ‘<‘

    for bolded line.

    #1501004
    David
    Staff
    Customer Support

    Hi there,

    you would need to use a Action Hook like so:

    add_action('generate_after_entry_content', function() {
      ?>
      // Your HTML Goes here 
      <?php
    });

    Or the simpler process is to just add your HTML to the a Hook Element:

    https://docs.generatepress.com/article/hooks-element-overview/

    #1501063
    Aleksey

    Thanks David, now my html works, but it puts author box outside <footer> tag: http://prntscr.com/v59gsv

    How can I place it inside <footer>?

    #1501101
    David
    Staff
    Customer Support

    There isn’t a hook inside there. Instead you would first need to unhook the footer meta:

    add_action( 'wp', function() {
          remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
    } );

    Then Hook back it back in with your own content:

    add_action('generate_after_entry_content', function() {
      ?>
      <footer class="entry-meta">
          // Your HTML Goes here 
    	<?php generate_entry_meta(); ?>
      </footer>
      
      <?php
    });
    #1501136
    Aleksey

    Brilliant! Working like a charm 🙂

    Thank you for your help!

    #1501144
    David
    Staff
    Customer Support

    You’re welcome

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