Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #797900

    I am using the enfold theme for the first time, and I really love this theme.
    I see that this theme comes with a feature to display the testimonials. I really like the way the testimonials are being displayed in the default grid layout. But they are all static content.

    On my website though, I want to have testimonials as a custom post type. I want to display every individual testimonial on its own page when I click on the person’s name, or picture or a Read More link.
    I created a custom post type called “Testimonials” using “CPT UI” plugin.
    In order to use exactly the same markup and styling that comes with the default testimonials in Enfold theme, I tried creating a shortcode for my custom post type “Testimonials” in function.php.

    I have a page called Testimonials. On this page I am using the shortcode [testimonials] to display all the testimonials with default pagination. The testimonials are being displayed perfectly fine as I want them to appear. The only problem is that the default numbered pagination is not showing up for some reason.

    Following is the code I have written in functions.php file to create the shortcode.

    
    /* SHORT CODE FOR ALL THE TESTIMONIALS */
    function all_testimonials_shortcode() {
    	$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    	//echo "Page numbers: " . $paged;
    	$loop = new WP_Query( 
    			array( 
    				'post_type' => 'testimonials', 
    				'paged' => $paged, 
    				'posts_per_page' => '4', 
    				'paginate' => 'yes', 
    				'use_main_query_pagination' => 'yes'
    			));
        
    	if ( $loop->have_posts() ) {
            
            $output = '';
    		while ( $loop->have_posts() ) { 
                $loop->the_post();
    
                $post_thumbnail_id = get_post_thumbnail_id( $post_id );
                $testimonial_permalink = get_permalink( $post_id );
                $excerpt = get_the_excerpt( $post_id );
                $designation = get_field( 'designation' );
                $testimonialTitle = get_the_title();
                $output .= "[av_testimonial_single  limit='1' href=" . $testimonial_permalink . " src=".$post_thumbnail_id ."  link='http://' linktext='']";
                $output .= $excerpt . "... <a href=" . $testimonial_permalink . ">Read More</a>";
                $output .= "<div class='avia-testimonial-meta-mini'>";
                $output .= "<div class='avia-testimonial-name'><strong>".$testimonialTitle."</strong></div>";
                $output .= "<div class='avia-testimonial-subtitle '>".$designation."</div>";
                $output .= "</div>";
                $output .= "[/av_testimonial_single]";
            }
    		// echo avia_pagination('$loop->max_num_pages', 'nav');
    		
            return do_shortcode("[av_testimonials style='grid' columns='2' grid_style='' interval='5' font_color='' custom_title='' custom_content='' admin_preview_bg='']". $output ."[/av_testimonials]");
    		
    		wp_reset_postdata();
    	}
    };
    add_shortcode('testimonials', 'all_testimonials_shortcode');

    The testimonials are now displayed fine, and they are displayed in this format:
    Testimonials

    For some reason, the pagination is not showing up. I want the pagination to be displayed like this:
    pages

    Can someone tell me if I am missing something in my code. Thanks.

    #798028

    Hey guys – Any ideas on this issue? Can someone point me in the right direction?

    #799401

    Hi,

    Thank you for using Enfold.

    Have you tried using the theme’s avia_pagination function? Please check the includes > loop-index.php file as reference.

    Best regards,
    Ismael

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