Advertisement
Guest User

Untitled

a guest
Jul 9th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. require_once 'simple_html_dom.php';
  3.  
  4. $home_cats_ids = get_field( 'home_cats_ids', get_option( 'page_on_front' ) );
  5. if ( $home_cats_ids ) {
  6. $cats_ids = implode( ',', $home_cats_ids );
  7. } else {
  8. $home_cats_ids = '6,7,8';
  9. }
  10.  
  11. // Вывод случайных материалов на главной
  12. get_posts( array(
  13. 'showposts' => 3,
  14. 'orderby' => 'rand',
  15. 'cat' => $home_cats_ids,
  16. ) );
  17.  
  18. if ( have_posts() ) :
  19. while ( have_posts() ) :
  20. the_post();
  21.  
  22. /* Здесь нужно вывести h1 записи вместо заголовка записи */
  23. $content = get_the_content();
  24. $html = str_get_html( $content );
  25. $h1 = $html->find( 'h1', 0 )->plaintext;
  26.  
  27. ?>
  28. <h1><?php echo esc_html( $h1 ); ?></h1>
  29. <?php
  30.  
  31. endwhile;
  32. endif;
  33. wp_reset_postdata();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement