[Plugin: WP-Testimonials] [WP-Testimonial] – Shortcode for Random Testimonial
-
Hi,
I used the WP-Testimonial Plug-In but I needed the random testimonial not in a Widget but as a Shortcode to place on my Homepage.
So I finally managed to add this function (see code below), so it would be great if it was added to the next release so I can update it without ruining my efforts ??
Thank you!!
/* show random testimonial(s) in SHORTCODE "[Testimonial-Random]" */ function sfstst_onerandomTwo() { global $wpdb; $table_name = $wpdb->prefix . "testimonials"; if (get_option('sfs_setlimit') == '') { $sfs_setlimit = 1; } else { $sfs_setlimit = get_option('sfs_setlimit'); } $randomT = $wpdb->get_results("SELECT testid, clientname, company, homepage, text_short FROM $table_name WHERE text_short !='' order by RAND() LIMIT $sfs_setlimit"); $retvaloTwo .= '<div id="sfstest-sidebar">'; foreach ($randomT as $randomT2) { $retvaloTwo .= '<blockquote>'; $retvaloTwo .= '<p>'; $retvaloTwo .= nl2br(stripslashes($randomT2->text_short)); $retvaloTwo .= '</p>'; $retvaloTwo .= '<p><cite>'; if ($randomT2->company != '') { $retvaloTwo .= stripslashes($randomT2->clientname).'<br />'; if ($randomT2->homepage != '') { $retvaloTwo .= '<a href="'.$randomT2->homepage.'" class="cite-link">'.stripslashes($randomT2->company).'</a>'; } else { $retvaloTwo .= stripslashes($randomT2->company); } } else { $retvaloTwo .= stripslashes($randomT2->clientname).''; } $retvaloTwo .= '</cite></p>'; $retvaloTwo .= '</blockquote>'; } // end loop $sfs_showlink = get_option('sfs_showlink'); $sfs_linktext = get_option('sfs_linktext'); $sfs_linkurl = get_option('sfs_linkurl'); if (($sfs_showlink == 'yes') && ($sfs_linkurl !='')) { if ($sfs_linktext == '') { $sfs_linkdisplay = 'Read More'; } else { $sfs_linkdisplay = $sfs_linktext; } $retvaloTwo .= '<div class="sfststreadmore"><a href="'.$sfs_linkurl.'">'.$sfs_linkdisplay.'</a></div>'; } $retvaloTwo .= '</div>'; return $retvaloTwo; } add_shortcode('Testimonial-Random', 'sfstst_onerandomTwo');
https://www.ads-software.com/extend/plugins/wp-testimonials/
- The topic ‘[Plugin: WP-Testimonials] [WP-Testimonial] – Shortcode for Random Testimonial’ is closed to new replies.