Search
 
SCRIPT & CODE EXAMPLE
 

PHP

testimonial custom post type and uses shortcode

function md_testimonial_loop() {
    ob_start();
  
    $args = array(
      "post_type"         => "testimonials",
      "posts_per_page"    => -1,
    );
  
    $the_query = new WP_Query($args);
  
    if ( $the_query->have_posts() ) {
      echo '<div class="slider" id="testi_slider">';
      while ( $the_query->have_posts() ) {
          $the_query->the_post();
          echo '<div class="testi_content">' . the_content() . '</div>';
          echo '<div class="testi_author">' . get_the_title() . '</div>';
  
          $rating = get_field('star_rating');
          if ($rating) :
            echo '<div class="testi_rating"><img src="http://localhost/md/staging/salty-lives/wp-content/uploads/2022/05/STAR-'. $rating .'.png" alt="'.get_the_title().'-rating" /></div>';
          else :
            echo '<div class="testi_rating"><img src="http://localhost/md/staging/salty-lives/wp-content/uploads/2022/05/STAR-5.png" alt="'.get_the_title().'-rating"/></div>';
          endif;
      }
      echo '</div>';
    } else {
      echo '<p>No testimonials review added for the website.</p>';
    }
  
    wp_reset_postdata();
    $output = ob_get_clean();
      return $output;
  
  }
  add_shortcode('md_testimonials_shortcode', 'md_testimonial_loop');
Comment

PREVIOUS NEXT
Code Example
Php :: how to link a external modules using href in php 
Php :: wordpress add block from single.php 
Php :: Call to a member function move() on null 
Php :: php pdo random multiple insert query 
Php :: php composer copy library to public vendor folder 
Php :: Set Countries To Appear At The Top Of The Caldera Forms Phone Field List 
Php :: laravel form collective add asterisk 
Php :: import separate graphql file laravel 
Php :: laravel cors error localhost 
Php :: show all errors in php 
Php :: <= in php 
Php :: pass address of array in php 
Php :: accessing class in php 
Php :: use compose with different php version debian linux 
Php :: laravel gigapay payout list 
Php :: php loop add class to first element 
Php :: symfony retun json 
Php :: echo fread($myfile,filesize("webdictionary.txt")); 
Php :: snippet doctrine orm with types 
Php :: pivot null in livewire refresh 
Php :: remove public path from url laravel 
Php :: X-Frame-Options may only be set via an HTTP header sent along with a document. It may not be set inside <meta. 
Php :: php prepared statement and conditional 
Php :: buddypress groups dropdown 
Php :: namespace autoload php 
Php :: get all routes in laravel 
Php :: auto reload page in chat php 
Php :: why are my css properties not being applied to php file 
Php :: PHP $argv echo with number of words 
Php :: laravel command Retrieve a specific option 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =