Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'simple_html_dom.php';
- $home_cats_ids = get_field( 'home_cats_ids', get_option( 'page_on_front' ) );
- if ( $home_cats_ids ) {
- $cats_ids = implode( ',', $home_cats_ids );
- } else {
- $home_cats_ids = '6,7,8';
- }
- // Вывод случайных материалов на главной
- get_posts( array(
- 'showposts' => 3,
- 'orderby' => 'rand',
- 'cat' => $home_cats_ids,
- ) );
- if ( have_posts() ) :
- while ( have_posts() ) :
- the_post();
- /* Здесь нужно вывести h1 записи вместо заголовка записи */
- $content = get_the_content();
- $html = str_get_html( $content );
- $h1 = $html->find( 'h1', 0 )->plaintext;
- ?>
- <h1><?php echo esc_html( $h1 ); ?></h1>
- <?php
- endwhile;
- endif;
- wp_reset_postdata();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement