Advertisement
trtlator

random post title on ticker

May 20th, 2021 (edited)
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <style>
  2.     /* OUTER CONTAINER */
  3. .tcontainer {
  4.   width: 100%;
  5.   overflow: hidden; /* Hide scroll bar */
  6. }
  7.  
  8. /* MIDDLE CONTAINER */
  9. .ticker-wrap {
  10.   width: 100%;
  11.   padding-left: 100%; /* Push contents to right side of screen */
  12.   background-color: #eee;
  13. }
  14.  
  15. /* INNER CONTAINER */
  16. @keyframes ticker {
  17.   0% { transform: translate3d(0, 0, 0); }
  18.   100% { transform: translate3d(-500%, 0, 0); }
  19. }
  20. .ticker-move {
  21.   /* Basically move items from right side of screen to left in infinite loop */
  22.   display: inline-block;
  23.   white-space:nowrap;
  24.   animation-iteration-count: infinite;
  25.   animation-timing-function: linear;
  26.   animation-name: ticker;
  27.   animation-duration: 20s;
  28. }
  29. .ticker-move:hover{
  30.   animation-play-state: paused; /* Pause scroll on mouse hover */
  31. }
  32.  
  33. /* ITEMS */
  34. .ticker-item{
  35.   display: inline-block; /* Lay items in a horizontal line */
  36.   padding: 0 2rem;
  37.  
  38.     }</style>
  39.  
  40. <div class="tcontainer"> <div class="ticker-wrap"><div class="ticker-move">
  41.  
  42.   <div class="ticker-item"><?php
  43.        $args=array(
  44.         'post_type' => 'post',
  45.                  
  46.          );
  47.       $random_post = new WP_Query ($args);
  48. if ($random_post->have_posts() ) {
  49.     while ($random_post->have_posts() ) {
  50.         $random_post->the_post();
  51.         echo '<div class="ticker-item"><a href="'.get_the_permalink().'">'.get_the_title().'</a></div>';
  52.     }
  53. }
  54.         }
  55.     }
  56.    
  57. ?>
  58.  <?php wp_reset_postdata(); ?>
  59. </div>
  60.  
  61. </div></div></div>
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement