• Друзья, подскажите пожалуйста, хочу добавить в материале количество просмотров. Есть код, но когда я вставляю в файл темы, то счетчик располагается не там где я хочу. Мне нужно чтобы счетчик был водной строке с датой публикации и автором. Подскажите, как сделать.
    Вот это нужно вставить
    <?php if ( function_exists( 'echo_tptn_post_count' ) ) { echo_tptn_post_count(); } ?>
    Это фрагмент файла single.php:

    <header class="vl-main-header">
    			<?php the_title( '<h1>', '</h1>' ); ?>
    		</header><!-- .entry-header -->
    
    		<?php while ( have_posts() ) : the_post(); ?>
    
    			<?php get_template_part( 'template-parts/content', 'single' ); ?>
    
    			<nav class="navigation post-navigation" role="navigation">

    Страница, с которой нужна помощь: [войдите, чтобы увидеть ссылку]

Просмотр 4 ответов — с 1 по 4 (всего 4)
  • вам нужно вставить его куда-то до <div class="entry-content">
    а еще точнее: в конец блока <div class="posted-on">

    Блок <div class="posted-on"> нашел только в одном файле template-tags.php. Вот фрагмент кода: echo '<div class="posted-on"><i class="fa fa-clock-o" aria-hidden="true"></i>' . $posted_on . '<span class="byline"> ' . $byline . '</span></div>'; Здесь нигде и не вставишь. Если вставляю — сайт не открывается.

    между последним закрывающим </span> и </div> попробуйте.

    Вот фрагмент файла, отвечающий за дату и автора в начале материала (я так считаю), вот куда здесь можно вставить данный код счетчика?

    if ( ! function_exists( 'viral_post_date' ) ) :
    /**
     * Prints HTML with meta information for the current post-date/time and author.
     */
    function viral_post_date() {
    	$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
    	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
    		$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
    	}
    
    	$time_string = sprintf( $time_string,
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_attr( get_the_modified_date( 'c' ) ),
    		esc_html( get_the_modified_date() )
    	);
    
    	$posted_on =  $time_string;
    
    	$byline = sprintf(
    		esc_html_x( 'от %s', 'post author', 'viral' ),
    		'<span class="author vcard">' . esc_html( get_the_author() ) . '</span>'
    	);
    
    	echo '<div class="posted-on"><i class="fa fa-clock-o" aria-hidden="true"></i>' . $posted_on . '<span class="byline"> ' . $byline . '</span></div>'; // WPCS: XSS OK.
    
    }
    endif;
Просмотр 4 ответов — с 1 по 4 (всего 4)
  • Тема «Количество просмотров в одну строку» закрыта для новых ответов.