Support » Plugin: Strong Testimonials » Creating a new layout to display testimonials

  • Resolved Raw Hasan

    (@rawhasan)


    Hi Chris,

    Thank you so much for developing this wonderful plug-in! My quest for the best free testimonial plug-in is finally over!! It is so easy to use with such flexibility!

    Please help me getting this layout to display my testimonials: http://prntscr.com/j9rrzx

    Best regards,
    Hasan

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Contributor Chris Dillon

    (@cdillon27)

    Hi Hasan,

    Nice mockup. That will require a custom template. Start here:
    https://strongplugins.com/document/strong-testimonials/custom-templates/

    The template uses a single function to print the custom fields selected in the view.

    <?php wpmtst_the_client(); ?>

    To print individual custom fields, use wpmtst_field:

    <?php wpmtst_field( 'client_name' ); ?>

    Star ratings require a little more:

    <?php wpmtst_star_rating_display( wpmtst_get_field( 'rating' ), 'in-view', true ); ?>

    And if you want to use the plugin stylesheet for the star ratings, enqueue it in your theme:

    function extra_styles() {
    	wp_enqueue_style( 'wpmtst-rating-display' );
    }
    add_action( 'wp_enqueue_scripts', 'extra_styles' );

    Categories require more too. In the template:

    <?php my_custom_template_category(); ?>

    And in your theme’s functions.php:

    /**
     * Print a list of the categories assigned to the current testimonial.
     * Used in a custom template.
     *
     * @param bool $echo
     * @return bool|string
     */
    function my_custom_template_category( $echo = true ) {
    	global $post;
    
    	$categories = get_the_terms( $post->ID, 'wpm-testimonial-category' );
    	if ( $categories && ! is_wp_error( $categories ) ) {
    		$list = array();
    		foreach ( $categories as $cat ) {
    			$list[] = $cat->name;
    		}
    		$html = join( ", ", $list );
    	}
    	else {
    		$html = '';
    	}
    
    	if ( $echo ) {
    		echo $html;
    		return true;
    	}
    
    	return $html;
    }

    (I plan to incorporate all that functionality into the wpmtst_field function eventually.)

    Thread Starter Raw Hasan

    (@rawhasan)

    Hi Chris,

    Thank you so much for such detailed help! Simply blown away! Really appreciate it!! 🙂

    With the help of your custom template documentation and some trial and error, I was able to generate a workable custom template for me: http://prntscr.com/j9w47j

    For the time being, it will do for me! I now am completely clueless about how can I customize the single testimonial page which is shown once I click the read more link of the testimonial.

    I need to customize this page to remove the author bio & the meta fields. Also need to add all the custom fields from the testimonial summery page.

    Please shed some light!

    Here is the page I am working on: https://nijhoom.com/review/

    If you make this template built-in on the plug-in and sell as an extension, I am sure you’ll get lots of customers, specially tour operators like me, who will love to have this for their sites.

    Best regards,
    Hasan

    Plugin Contributor Chris Dillon

    (@cdillon27)

    I’m glad to help. I always enjoy discovering how the plugin is used.

    The individual testimonial uses your theme’s single post template. I have spent many hours trying to build a bulletproof, theme-agnostic replacement without success. WordPress is simply not designed to allow that to happen.

    At the very least, you can create another testimonial view in Single Template mode and select the custom fields to append to the testimonial content.

    Every theme is coded differently. For most themes, the best approach is to create a single testimonial template by copying the single post template. WordPress has a built-in mechanism for selecting the appropriate template based on the post type.

    In many cases, it may be as simple as copying and renaming one or two files in your theme.

    In some cases, it can be rather complex if the theme employs a framework system or makes heavy use of action hooks and filters.

    https://developer.wordpress.org/themes/basics/template-hierarchy/#single-post

    Our post type is ‘wpm-testimonial’ so the filename would be ‘single-wpm-testimonial.php’.

    Once the single testimonial template is created, you can add or remove elements like the author bio & meta fields. I also recommend adding Previous/Next navigation to keep your visitors clicking through.

    Your theme support may be able to instruct you on building the single template. If you find that overwhelming, consider hiring a developer for an hour or two to build the single template and maybe finish the custom template for you.
    https://www.fiverr.com/search/gigs?query=wordpress
    https://www.upwork.com/o/profiles/browse/?q=wordpress

    Thread Starter Raw Hasan

    (@rawhasan)

    Thanks a lot Chris!

    By copying the single.php to my child theme and renaming it as you said, I was able to modify it and remove the meta fields in the bottom. I now have a workable clean single page for the testimonials! Thank you so much!! 🙂

    I now just need to add the custom fields of the testimonials below the content. I’ve copied the lines from the testimonial template to the renamed single.php, but it is not displaying the field values.

    Will appreciate some light on this as usual! 🙂

    Best regards,
    Hasan

    Plugin Contributor Chris Dillon

    (@cdillon27)

    First, try clearing your Rocket cache. It probably didn’t detect the change.

    It appears you are using the Single Template view mode. If so, have you selected the custom fields in that view? If not, post just the lines you copied from the template here. (The moderators discourage really long snippets. If the entire single.php is less than 20 lines or so, post the whole thing. Or paste the whole thing at pastebin or pastee then add a link here.)

    Thread Starter Raw Hasan

    (@rawhasan)

    These are the lines I copied:

    
    <div class="testimonial-content">
        <?php wpmtst_the_thumbnail(); ?>
        <div class="testimonial-client">
            <?php wpmtst_the_client(); ?>
        </div>
        <div class="clear"></div>
    </div>
    

    Here is the full single.php: https://pastebin.com/X0MSbkj3

    Rocket is not any issue, as it does not cache for the logged-in users.

    Best regards,
    Hasan

    Plugin Contributor Chris Dillon

    (@cdillon27)

    Those functions only work within a view. Use standard WordPress functions or wpmtst_field instead:

    <div><?php the_post_thumbnail(); ?></div>
    <div><?php wpmtst_field( 'client_name' ); ?></div>
    Thread Starter Raw Hasan

    (@rawhasan)

    Thanks a million Chris!!!! 🙂

    I was able to add the client name, category, featured image, and location on the post. But the post_date function is not working:

    <div><?php wpmtst_field( 'post_date' ); ?></div>

    Can you please tell me what’s wrong with the date field?

    • This reply was modified 4 years, 3 months ago by Raw Hasan.
    Plugin Contributor Chris Dillon

    (@cdillon27)

    That’s a standard WordPress field, not a custom field.

    <?php the_date(); ?>

    https://codex.wordpress.org/Function_Reference/the_date

    Thread Starter Raw Hasan

    (@rawhasan)

    That worked perfectly!

    I must say, this is the best support I’ve ever received from the author of any free plug-in! Thank you so much for the wonderful support! I am going to write a glowing review for the plug-in.

    All the best for Strong Testimonials!! 🙂

    Regards,
    Hasan

    Plugin Contributor Chris Dillon

    (@cdillon27)

    You’re very welcome! Good luck with your site.

    Cheers,
    Chris

    Hello.
    Thanks for your plugin
    I have a problem
    <? php echo do_shortcode (‘[testimonial_view cat = “category” id = 2]’); ?>
    but the site displays all the reviews, how to make a conclusion of a certain category

    • This reply was modified 4 years, 3 months ago by oleq.
    Plugin Contributor Chris Dillon

    (@cdillon27)

    @oleq,

    This issue is resolved. Please start a new topic and include a link to your site if possible.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Creating a new layout to display testimonials’ is closed to new replies.