WordPress.org

Ready to get started?Download WordPress

Forums

HMS Testimonials
[resolved] Display Field Names (5 posts)

  1. KevM1970
    Member
    Posted 10 months ago #

    Hi

    Excuse my ignorance, I am new to WordPress, but I found your Testimonial Plugin and it works great, but can you tell me how I can get the template output to include the field names ?

    For example I have a testimonial, I have added Tags as a Custom Field, that when its output to a static page displays :

    01/08/2013
    Bob the Builder, A Town, A State
    The painting was great many thanks !
    Internal Decoration

    What I would like it to display, is the field names as well, for example :

    Testimonial Date : 01/08/2013
    Client Name : Bob the Builder, A Town, A State
    Testimonial : "The painting was great many thanks !"
    Tags : Internal Decoration

    Can you help please ?

    Thanks
    Kev

    http://wordpress.org/plugins/hms-testimonials/

  2. Jeff K
    Member
    Plugin Author

    Posted 10 months ago #

    Hey Kev,

    Add the following to your themes functions.php file. If you go to Appearance -> Editor, on the right hand side you should see a "Theme Functions" link which will allow you to edit the file.

    function hms_testimonials_date( $value ) {
    	return 'Testimonial Date : ' . $value;
    }
    
    function hms_testimonials_source( $value ) {
    	return 'Client Name : '. $value;
    }
    
    function hms_testimonials_testimonial( $value ) {
    	return 'Testimonial : '. $value;
    }
    
    function hms_testimonials_tags( $value ) {
    	return 'Tags : '. $value;
    }
    
    add_filter('hms_testimonials_system_date', 'hms_testimonials_date');
    add_filter('hms_testimonials_system_source', 'hms_testimonials_source');
    add_filter('hms_testimonials_system_testimonial', 'hms_testimonials_testimonial');
    add_filter('hms_testimonials_cf_tags', 'hms_testimonials_tags');

    Jeff

  3. KevM1970
    Member
    Posted 10 months ago #

    Hi Jeff

    Many thanks for that, I have added the code and the Field Names now appear.

    Question now is how do I control the formatting of the testimonial, for example, can I have the Field Names in Bold ?

    I see in the documentation section of the Plugin that there are some CSS Classes, do I use these and if so how do I use them ?

    Kev

  4. Jeff K
    Member
    Plugin Author

    Posted 10 months ago #

    Hey Kev,

    The plugin wasn't really setup to add field names. I just so happened to create filters that allowed the code I posted to work.

    You can do 1 of to things, both of which modify the code I posted.

    1. Add strong tags around the field names.

    Ex.

    function hms_testimonials_date( $value ) {
    	return '<strong>Testimonial Date :</strong> ' . $value;
    }

    2. Add a span and use CSS to modify the style to each one.

    Ex.

    function hms_testimonials_date( $value ) {
    	return '<span class="hms-testimonial-label">Testimonial Date :</span> ' . $value;
    }

    Then in your themes style.css add:

    .hms-testimonial-label { font-weight: bold; }

    Either one will work. The second gives you more flexibility for the future.

    Jeff

  5. KevM1970
    Member
    Posted 10 months ago #

    Hi Jeff

    Many thanks, that's a great help, I will give it a go.

    Thanks for your help and writing a great plugin

    Kev

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.