• Resolved manav kalra

    (@manavkalra15)


    Hello, Thanks for awesome theme. I am using your theme on my multiple sites from 2020.

    I am using Ajax Load more plugin to replace pagination with load more button on home & archive pages in generatepress.

    I copied Repeater Template for ajax plugin from theme content.php
    you can check below

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
    	<div class="inside-article">
    		<?php
    		/**
    		 * generate_before_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_featured_page_header_inside_single - 10
    		 */
    		do_action( 'generate_before_content' );
    
    		if ( generate_show_entry_header() ) :
    			?>
    			<header <?php generate_do_attr( 'entry-header' ); ?>>
    				<?php
    				/**
    				 * generate_before_entry_title hook.
    				 *
    				 * @since 0.1
    				 */
    				do_action( 'generate_before_entry_title' );
    
    				if ( generate_show_title() ) {
    					$params = generate_get_the_title_parameters();
    
    					the_title( $params['before'], $params['after'] );
    				}
    
    				/**
    				 * generate_after_entry_title hook.
    				 *
    				 * @since 0.1
    				 *
    				 * @hooked generate_post_meta - 10
    				 */
    				do_action( 'generate_after_entry_title' );
    				?>
    			</header>
    			<?php
    		endif;
    
    		/**
    		 * generate_after_entry_header hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_post_image - 10
    		 */
    		do_action( 'generate_after_entry_header' );
    
    		$itemprop = '';
    
    		if ( 'microdata' === generate_get_schema_type() ) {
    			$itemprop = ' itemprop="text"';
    		}
    
    		if ( generate_show_excerpt() ) :
    			?>
    
    			<div class="entry-summary"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
    				<?php the_excerpt(); ?>
    			</div>
    
    		<?php else : ?>
    
    			<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
    				<?php
    				the_content();
    
    				wp_link_pages(
    					array(
    						'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
    						'after'  => '</div>',
    					)
    				);
    				?>
    			</div>
    
    			<?php
    		endif;
    
    		/**
    		 * generate_after_entry_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_footer_meta - 10
    		 */
    		do_action( 'generate_after_entry_content' );
    
    		/**
    		 * generate_after_content hook.
    		 *
    		 * @since 0.1
    		 */
    		do_action( 'generate_after_content' );
    		?>
    	</div>
    </article>

    Load more button is working by using this repeater template. But, the only problem I am getting is “date, by author” after post title

    &

    “category, tag & leave a comment” after read more are not showing.


    Post title, featured image & post excerpt showing.

    Can anyone please tell me changes to make in above code to show “date, by author, category, tag & leave a comment” ?

    Thanks in Advance

Viewing 12 replies - 16 through 27 (of 27 total)
  • Thread Starter manav kalra

    (@manavkalra15)

    Everything is working fine except data not coming by using

    do_action( 'generate_after_entry_title' );
    
    do_action( 'generate_after_entry_content' );

    Change the snippet to this:

    add_filter( 'generate_header_entry_meta_items', function( $items ) {  
            return array( 'author', 'date', 'comments-link', 'categories');
        
    } );
    
    add_action( 'wp', function() {
            add_filter( 'generate_show_comments', '__return_true' );
        
    } );
    Thread Starter manav kalra

    (@manavkalra15)

    Done, still no change.

    How did you add the PHP snippet?

    Thread Starter manav kalra

    (@manavkalra15)

    I added in like this in plugin repeater template

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
    	<div class="inside-article">
    		<?php
    		/**
    		 * generate_before_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_featured_page_header_inside_single - 10
    		 */
    		do_action( 'generate_before_content' );
    
    		if ( generate_show_entry_header() ) :
    			?>
    			<header <?php generate_do_attr( 'entry-header' ); ?>>
    				<?php
    				/**
    				 * generate_before_entry_title hook.
    				 *
    				 * @since 0.1
    				 */
    				do_action( 'generate_before_entry_title' );
    
    				if ( generate_show_title() ) {
    					$params = generate_get_the_title_parameters();
    
    					the_title( $params['before'], $params['after'] );
    				}
    
    				/**
    				 * generate_after_entry_title hook.
    				 *
    				 * @since 0.1
    				 *
    				 * @hooked generate_post_meta - 10
    				 */
    				add_filter( 'generate_header_entry_meta_items', function( $items ) {  
            return array( 'author', 'date', 'comments-link', 'categories');
        
    } );
    				?>
    			</header>
    			<?php
    		endif;
    
    		/**
    		 * generate_after_entry_header hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_post_image - 10
    		 */
    		
    		do_action( 'generate_after_entry_header' );
    
    		$itemprop = '';
    
    		if ( 'microdata' === generate_get_schema_type() ) {
    			$itemprop = ' itemprop="text"';
    		}
    
    		if ( generate_show_excerpt() ) :
    			?>
    
    			<div class="entry-summary"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
    				<?php the_excerpt(); ?>
    			</div>
    
    		<?php else : ?>
    
    			<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
    				<?php
    				the_content();
    
    				wp_link_pages(
    					array(
    						'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
    						'after'  => '</div>',
    					)
    				);
    				?>
    			</div>
    
    			<?php
    		endif;
    
    		/**
    		 * generate_after_entry_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_footer_meta - 10
    		 */
    		add_action( 'wp', function() {
            add_filter( 'generate_show_comments', '__return_true' );
        
    } );
    
    		/**
    		 * generate_after_content hook.
    		 *
    		 * @since 0.1
    		 */
    		do_action( 'generate_after_content' );
    		?>
    	</div>
    </article>

    Can you try adding it through a plugin called Code Snippets?

    Thread Starter manav kalra

    (@manavkalra15)

    Done as you said, I added this snippet in code snippet plugin.

    Still no change after clicking load more.

    Thread Starter manav kalra

    (@manavkalra15)

    I find out that generatepress hooks not working in plugin repeater template, can you please provide me direct html(with div tag & author link) and php code to show date, by author in place of do_action( ‘generate_after_entry_title’ ); hook

    & direct code (php and html with div tag with link) to show category, tag, leave a comment in place of do_action( ‘generate_after_entry_content’ );

    For example: I tried

    <?php the_author(); ?>

    It’s showing author but link to author profile and div tag is missing.

    ying

    (@yingscarlett)

    Try this template:

    <?php
    /**
     * The template for displaying posts within the loop.
     *
     * @package GeneratePress
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?> <?php generate_do_microdata( 'article' ); ?>>
    	<div class="inside-article">
    		<?php
    		/**
    		 * generate_before_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_featured_page_header_inside_single - 10
    		 */
    		do_action( 'generate_before_content' );
    
    		if ( generate_show_entry_header() ) :
    			?>
    			<header <?php generate_do_attr( 'entry-header' ); ?>>
    				<?php
    				/**
    				 * generate_before_entry_title hook.
    				 *
    				 * @since 0.1
    				 */
    				do_action( 'generate_before_entry_title' );
    
    				if ( generate_show_title() ) {
    					$params = generate_get_the_title_parameters();
    
    					the_title( $params['before'], $params['after'] );
    				}
    
    				/**
    				 * generate_after_entry_title hook.
    				 *
    				 * @since 0.1
    				 *
    				 * @hooked generate_post_meta - 10
    				 
    				do_action( 'generate_after_entry_title' );*/
                                    generate_post_meta();
    				?>
    			</header>
    			<?php
    		endif;
    
    		/**
    		 * generate_after_entry_header hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_post_image - 10
    		 */
    		do_action( 'generate_after_entry_header' );
    
    		$itemprop = '';
    
    		if ( 'microdata' === generate_get_schema_type() ) {
    			$itemprop = ' itemprop="text"';
    		}
    
    		if ( generate_show_excerpt() ) :
    			?>
    
    			<div class="entry-summary"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
    				<?php the_excerpt(); ?>
    			</div>
    
    		<?php else : ?>
    
    			<div class="entry-content"<?php echo $itemprop; // phpcs:ignore -- No escaping needed. ?>>
    				<?php
    				the_content();
    
    				wp_link_pages(
    					array(
    						'before' => '<div class="page-links">' . __( 'Pages:', 'generatepress' ),
    						'after'  => '</div>',
    					)
    				);
    				?>
    			</div>
    
    			<?php
    		endif;
    
    		/**
    		 * generate_after_entry_content hook.
    		 *
    		 * @since 0.1
    		 *
    		 * @hooked generate_footer_meta - 10
    		 
    		do_action( 'generate_after_entry_content' );*/
                     generate_footer_meta();
    
    		/**
    		 * generate_after_content hook.
    		 *
    		 * @since 0.1
    		 */
    		do_action( 'generate_after_content' );
    		?>
    	</div>
    </article>
    
    • This reply was modified 1 year, 8 months ago by ying.
    Thread Starter manav kalra

    (@manavkalra15)

    And its done, Thanks alot !!!!

    Theme Support, That’s the main reason I am using Generatepress on my all sites.

    Once again thanks & I really appreciate Generatepress support!

    ying

    (@yingscarlett)

    You are welcome!

    Glad to hear that ??

    Thread Starter manav kalra

    (@manavkalra15)

    My issue is solved, I am marking this as resolved.

Viewing 12 replies - 16 through 27 (of 27 total)
  • The topic ‘Few elements not loading in post snippet when using AJax Load More’ is closed to new replies.