2015-06-12 3 views
1

У меня есть эта ссылка:Почему не отображается время на карте? Wordpress

http://www.dg-design.ch/blog/page/2/

КОД PHP:

<?php while (have_posts()) : the_post(); ?> 

    <?php if($wp_query->current_post == 0){ ?> 
     <li class="block first-post"> 
      <a href="<?php the_permalink(); ?>" class="fancybox-iframe"><?php the_post_thumbnail('vantage-grid-loop'); ?></a> 
      <h3><a href="<?php the_permalink(); ?>" class="fancybox-iframe"><?php the_title(); ?></a></h3><br><p class="italic"><?php the_date(); ?></p> 
      <p><?php echo substr(get_the_content(),0,600).'...'; ?></p> 
     </li> 
    <?php } else if($wp_query->current_post > 0 && $wp_query->current_post < 5) { ?> 
    <li class="block"> 
     <a href="<?php the_permalink(); ?>" class="fancybox-iframe"><?php the_post_thumbnail('blog'); ?></a> 
     <h3><a href="<?php the_permalink(); ?>" class="fancybox-iframe"><?php echo substr(get_the_title(),0,20).'...'; ?></a></h3><br> 
       <p class="italic"> <?php the_date(); ?></p> 
     <p><?php echo substr(get_the_content(),0,70).'...'; ?></p> 
    </li> 
    <?php } else { ?> 
    <li class="block"> 
     <a href="<?php the_permalink(); ?>" class="fancybox-iframe"><?php the_post_thumbnail('blog'); ?></a> 
     <h3><a href="<?php the_permalink(); ?>" class="fancybox-iframe"><?php the_title(); ?></a></h3><br> 
<p class="italic"><?php the_date(); ?></p> 
     <p><?php echo substr(get_the_content(),0,600).'...'; ?></p> 
    </li> 
    <?php } ?> 

     <?php //get_template_part('content', get_post_format()); ?> 

    <?php endwhile; ?> 

я поставил картину лучше, что они хотят понять.

enter image description here

На первой странице блога, и отображается дата, на остальных страницах не показывается и не понимаю, почему.

Вы можете помочь мне решить эту проблему?

Заранее благодарен!

+0

попробуйте

+0

Спасибо! Это решение – Cristi

ответ

0

Проверьте скриншот и проверьте, правильно ли выполнена настройка. enter image description here

+0

Проверено на моем сайте эта кнопка – Cristi

0

Чтобы получить дату для сообщений, вам необходимо написать get_the_date(). Теперь вы должны разместить этот код в файле, который отвечает за отображение другого сообщения.

+0

Я пробовал с этим методом, но не работал – Cristi

0

При наличии нескольких сообщений на странице, опубликованной в ОДИН ДЕНЬ, the_date() отображает только дату первого сообщения.

Please Read this

0

@Shashank Singh

Связанное решающий вещи, хотя.

- Использование Ниже одноместный сообщение Страницы -

Вот печать функции в вопросе.

function the_date($d = '', $before = '', $after = '', $echo = true) { 
    global $currentday, $previousday; 

    if ($currentday != $previousday) { 
     $the_date = $before . get_the_date($d) . $after; 
     $previousday = $currentday; 

     /** 
     * Filter the date a post was published for display. 
     * 
     * @since 0.71 
     * 
     * @param string $the_date The formatted date string. 
     * @param string $d  PHP date format. Defaults to 'date_format' option 
     *       if not specified. 
     * @param string $before HTML output before the date. 
     * @param string $after HTML output after the date. 
     */ 
     $the_date = apply_filters('the_date', $the_date, $d, $before, $after); 

     if ($echo) 
      echo $the_date; 
     else 
      return $the_date; 
    } 

    return null; 
} 

Params:

$ д

(string) (Optional) PHP date format defaults to the date_format option if not specified. 

Default value: '' 

$ до того

(string) (Optional) Output before the date. 

Default value: '' 

$ после того, как

(string) (Optional) Output after the date. 

Default value: '' 

$ эхо

(bool) (Optional) default is display. Whether to echo the date or return it. 

Default value: true 

https://developer.wordpress.org/reference/functions/the_date/

Так что для того, чтобы работать вы должны были бы сделать что-то вроде the_date('','<p class="italic">, '</p>');

- Важное примечание -

Запомнить эта префиксная функция the_ предназначены для отображения, а get_the_ предназначены для обработки данных.

Смежные вопросы