Server : Apache System : Linux cs317.bluehost.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : andertr9 ( 1047) PHP Version : 8.2.18 Disable Function : NONE Directory : /home1/andertr9/public_html/wp-content/themes/ssp-starter/includes/shortcodes/ |
Upload File : |
<?php if ( ! function_exists( 'ssp_starter_shortcode_testionials' )) { function ssp_starter_shortcode_testionials( $atts , $content = null ) { extract( shortcode_atts( array( 'theme' => 'default' , 'count' => 4 , 'quote' => 0 , 'ratings' => 0 , ) , $atts )); $pageLink = get_the_permalink( ); $out = '<div class="testimonials">'; $count = ( $count ) ? $count : -1; $page = get_query_var( 'paged' ); $page = ( $page ) ? $page : 1; $offset = ( $page > 1 ) ? ( $page - 1 ) * $count : 0; $args = array( 'post_type' => 'testimonial', 'posts_per_page' => $count, 'offset' => $offset, ); if ( $ratings ) { $args[ 'meta_key' ] = '_testimonial_star'; $args[ 'meta_value' ] = $ratings; } $testimonials = new WP_Query( $args ); if ( $testimonials->have_posts( )) { while( $testimonials->have_posts( )) { $testimonials->the_post( ); $out .= '<div class="testimonial">'; if ( $theme == 'default' ) { $content = ''; $content .= ( $quote ) ? '<span class="quote">“</span>' : ''; $content .= get_the_content( ); $content .= ( $quote ) ? '<span class="quote">”</span>' : ''; $content = wpautop( $content ); $out .= '<div class="content">'; $out .= $content; $out .= '</div>'; $out .= '<h4 class="client-name">' . get_post_meta( get_the_ID( ) , 'client-name' , 'true' ) . '</h4>'; $out .= '<h5 class="client-address">' . get_post_meta( get_the_ID( ) , 'client-address' , 'true' ) . '</h5>'; } $out .= '</div>'; } } $out .= '</div>'; $out .= '<div class="post-links">'; if ( $page > 1 ) $out .= '<a href="' . $pageLink . '?paged=' . ( $page - 1 ) . '" class="button"> Previous </a>'; if ( $page < $Testimonials->max_num_pages ) $out .= '<a href="' . $pageLink . '?paged=' . ( $page + 1 ) . '" class="button"> Next </a>'; $out .= '</div>'; wp_reset_postdata( ); return $out; } } add_shortcode( 'testimonials' , 'ssp_starter_shortcode_testionials' );