- Поисковые системы
- Практика оптимизации
- Трафик для сайтов
- Монетизация сайтов
- Сайтостроение
- Социальный Маркетинг
- Общение профессионалов
- Биржа и продажа
- Финансовые объявления
- Работа на постоянной основе
- Сайты - покупка, продажа
- Соцсети: страницы, группы, приложения
- Сайты без доменов
- Трафик, тизерная и баннерная реклама
- Продажа, оценка, регистрация доменов
- Ссылки - обмен, покупка, продажа
- Программы и скрипты
- Размещение статей
- Инфопродукты
- Прочие цифровые товары
- Работа и услуги для вебмастера
- Оптимизация, продвижение и аудит
- Ведение рекламных кампаний
- Услуги в области SMM
- Программирование
- Администрирование серверов и сайтов
- Прокси, ВПН, анонимайзеры, IP
- Платное обучение, вебинары
- Регистрация в каталогах
- Копирайтинг, переводы
- Дизайн
- Usability: консультации и аудит
- Изготовление сайтов
- Наполнение сайтов
- Прочие услуги
- Не про работу
Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий
Нужен плагин, который выводит под статьей похожие записи как "Yet Another Related Posts", только еще превью картинки нужно, не просто текст! Спасибо
можно без плагина.
вставьте в файл functions.php код:
function ordered_thumbnails( $display = 'true', $class='' ) {
global $post;
// get all image attachments for this post
$images = get_children( array( 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', order=>"asc" ) );
// if the post has image attachments
if( $images !== false ) {
// find the image in position 1
foreach($images as $i) {
if ( $i->menu_order == 1 ) {
$img_id = $i->ID;
}
}
// if the images were unordered
if ( $img_id == '' ) {
$i = array_slice( $images, 0, 1 );
$img_id = $i[0]->ID;
}
// get image data
$image = wp_get_attachment_image_src( $img_id, 'thumbnail' );
$result = array(
'url' => $image[0],
'width' => $image[1],
'height' => $image[2]
);
// should the image be displayed or should data be returned as an array?
if ( $display == 'true' ) {
return _e( '<img src="'.$result['url'].'" width="'.$result['width'].'" height="'.$result['height'].'" class="'.$class.'" />' );
} else {
return $result;
}
} else {
// post does not have any image attachments
return (bool) false;
}
}
function ordered_thumbnails_medium( $display = 'true', $class='' ) {
global $post;
// get all image attachments for this post
$images = get_children( array( 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', order=>"asc" ) );
// if the post has image attachments
if( $images !== false ) {
// find the image in position 1
foreach($images as $i) {
if ( $i->menu_order == 1 ) {
$img_id = $i->ID;
}
}
// if the images were unordered
if ( $img_id == '' ) {
$i = array_slice( $images, 0, 1 );
$img_id = $i[0]->ID;
}
// get image data
$image = wp_get_attachment_image_src( $img_id, 'medium' );
$result = array(
'url' => $image[0],
'width' => $image[1],
'height' => $image[2]
);
// should the image be displayed or should data be returned as an array?
if ( $display == 'true' ) {
return _e( '<img src="'.$result['url'].'" width="'.$result['width'].'" height="'.$result['height'].'" class="'.$class.'" />' );
} else {
return $result;
}
} else {
// post does not have any image attachments
return (bool) false;
}
}
// create template tag "ordered_thumbnails"
add_action( 'ordered_thumbnails', 'ordered_thumbnails', 2 );
// Add Post Thumbnail Theme Support
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
add_image_size( 'featured', 200, 150, true );
}
//get thumbnail
function postimage($size=medium) {
if ( $images = get_children(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => 1,
'order' => 'ASC',
'post_mime_type' => 'image',)))
{
foreach( $images as $image ) {
$attachmentimage=wp_get_attachment_image( $image->ID, $size );
echo $attachmentimage.apply_filters('the_title', $parent->post_title);
}
}
}
//check any attachment
function checkimage($size=medium) {
if ( $images = get_children(array(
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => 1,
'post_mime_type' => 'image',)))
{
foreach( $images as $image ) {
$attachmentimage=wp_get_attachment_image( $image->ID, $size );
return $attachmentimage;
}
}
}
и в файл single.php в нужное место код:
<div>
<?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, // Number of related posts that will be shown.
'caller_get_posts'=> 1
);
$rp_query = new wp_query($args);
endif;
if($rp_query):
if($rp_query->have_posts()) ?>
<?php while ($rp_query->have_posts()): $rp_query->the_post(); ?>
<div style="width:210px;padding:10px;text-align:center;display:inline-block;position:relative;vertical-align:top;float:left;" >
<div style="text-align:center;"><a href="<?php the_permalink() ?>" title="<?php the_title('', ''); ?>"><?php ordered_thumbnails(); ?></div>
<div style="text-align:center;"><?php the_title(); ?></a></div>
</div>
</div>
<?php endwhile; ?>
<?php else: ?>
<div><?php _e("Матрица свободна, Нео...",""); ?></div>
<?php endif; wp_reset_query(); ?>
</div>
что-то у вас с div напутано
если поправите, то это будет только приветствоваться.
Я пользуюсь вот таким. Если чуть-чуть подогнать под дизайн, получается очень даже ничего.
А какие еще плагины есть?
Contextual Related Posts. Можно настроить — показывать только текстом или с миниатюрами.
Есть вот такой - RELATED POST with THUMBNAIL. А тут описание. Но он с 2008 не обновлялся, кто его знает работает ли.
Есть еще Contextual Related Posts. Тут описание и руссификатор. Этот по-новее будет.