Wordpress - вывод похожих записей без плагина

R1
На сайте с 26.10.2015
Offline
40
298

Помогите пожалуйста вставить код после текста статьи -

<?php

$tags = wp_get_post_tags($post->ID);
if ($tags) {
$tag_ids = array();
foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
$args=array(
'tag__in' => $tag_ids,
'post__not_in' => array($post->ID),
'showposts'=>5, // Количество статей, которые будут показаны.
'caller_get_posts'=>1
);
$my_query = new wp_query($args);
if( $my_query->have_posts() ) {
echo '<h3>Похожие записи</h3><ul>';
while ($my_query->have_posts()) {
$my_query->the_post();
?>
<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php
}
echo '</ul>';
}
}
?>

на страницу -

<?php

/**
* The Template for displaying all single posts
*
* @package WordPress
* @subpackage Twenty_Fourteen
* @since Twenty Fourteen 1.0
*/

get_header(); ?>
<?php
if ( function_exists('yoast_breadcrumb') ) {
yoast_breadcrumb('
<p id="breadcrumbs">','</p>
');
}
?>

<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
// Start the Loop.
while ( have_posts() ) : the_post();

/*
* Include the post format-specific template for the content. If you want to
* use this in a child theme, then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/
get_template_part( 'content', get_post_format() );


// Previous/next post navigation.
twentyfourteen_post_nav();

// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile;
?>

</div><!-- #content -->
</div><!-- #primary -->
<?php
get_sidebar( 'content' );
get_sidebar();
get_footer();

Пробовал по разному вставлять - страничка перестает загружаться

Советские военные фильмы (https://kino-o-voine.ru)
altezzik
На сайте с 06.11.2011
Offline
247
#1
ruslan1012:
Пробовал по разному вставлять - страничка перестает загружаться

Включите отладочный режим, увидите ошибку. Скорее всего, ошибка в разметке, открывающих и закрывающих тегах php

R1
На сайте с 26.10.2015
Offline
40
#2
altezzik:
Включите отладочный режим, увидите ошибку. Скорее всего, ошибка в разметке, открывающих и закрывающих тегах php

Тоже грешу на это.

Вот такая ошибка - Syntax error, unexpected "<"

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий