Ian Saras
asked 6 years ago

I would like to show the different projects in a random order every time someone visits my website, the same way as can be done with “Clients”  or with “Testimonials” in the shortcodes.php. How can I make that happen?

1 Answers
DominicStaff
answered 6 years ago

Hi Ian,
To display  “Client, Testimonials” randomly in the site. You can log in to Dashboard > Pages >  Open the “Happy Clients,  Awesome Team “page > Click the ” Client, Testimonials” on the mceEditor then select the Random.
See the screenshot:
 
To display “Project, Blog, Team” randomly in the site. Please do as the following:
Step1: Open the shortcode.php file in the folder path “wp-content\themes\dw-page-modern\inc”
Step2: Find the
/* Project shortcode
– Line 313 add the following code: ‘orderby’ => ‘none’
– Line 329 replace the following code:

 $the_query = new WP_Query( 'post_type=project'.$pro_cat.'&posts_per_page='.$number );

With new code:

 $the_query = new WP_Query( 'post_type=project'.$pro_cat.'&posts_per_page='.$number.'&orderby='.$orderby );

See the Screenshot:
 
/* Team Shortcode for OnePage
– Line 512 add the following code: ‘orderby’ => ”
– line 534 to 536 add the following code

  if ($orderby == 'rand') {
              shuffle($users);
         }

See the screenshot:
 
/* Blog shortcode
– line 82 add the following code : ‘orderby’ => ‘none’
– line 96 replace the following code :

 $the_query = new WP_Query($blog_cat.'&posts_per_page='.$number );

With new code:

 $the_query = new WP_Query($blog_cat.'&posts_per_page='.$number.'&orderby='.$orderby );ế

See the screenshot:

Step3: log in to Dashboard > Pages > Open the pages > Click the “Project, Team, Blog” icon on the mceEditor then insert
See the screenshot:
 
Step4: After inserting, You will get a shortcode (Example: [onepage_projects numer=” ” row=”2 ” col=”4″ cat=””])
You need to add the orderby=”rand”  in the shortcode ( Example: [onepage_projects numer=” ” row=”2 ” col=”4″ cat=”” orderby=”rand”] )
See the screenshot:
 
  Hope this helps!

Ian Saras
replied 6 years ago

Thanks Dominic!

Powered by DW Question & Answer Pro