Skip to content

Instantly share code, notes, and snippets.

< ?php
//По умолчанию выводится 5 постов
$tags = wp_get_post_tags($post->ID);
if ($tags) {
echo '<h2>Похожие записи</h2>';
$first_tag = $tags[0]->term_id;
$args=array(
'tag__in' => array($first_tag),
'post__not_in' => array($post->ID),
'showposts'=>5,
<h2>Популярные записи</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
#popular-comments { list-style:none; width:360px; } /*Ширина блока*/
#popular-comments li { overflow:auto; margin:10px 0px; border-bottom:1px solid #E6E6E6; padding-bottom:5px; } /*Стиль для списка записей*/
#popular-comments li img { float:left; margin-right:10px; border:4px solid #EEEEEE;} /*Стиль миниатюр*/
#popular-commentss li a { text-decoration:none; font-weight:bold; color:#1e292b;} /*Стиль активной ссылки*/
#popular-comments li p { margin-top:10px; }
<h2>Твиттер </h2>
<?php
$username = "you_name"; // Ваш ник в twitter.
$limit = "5"; // Количество выводимых твитов.
$prefix = "";
$suffix = "";
$tweetprefix = "";
$tweetsuffix = "<br>";
<?php
function the_breadcrumb() {
echo '';
if (!is_home()) {
echo '<a href="';
echo get_option('home');
echo '">';
echo 'Home';
echo "</a> &raquo; ";
if (is_category() || is_single()) {
<?php
function add_more_buttons($buttons) {
$buttons[] = 'hr';
$buttons[] = 'del';
$buttons[] = 'sub';
$buttons[] = 'sup';
$buttons[] = 'fontselect';
$buttons[] = 'fontsizeselect';
$buttons[] = 'cleanup';
$buttons[] = 'styleselect';
add_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags' );
function appthemes_add_quicktags() {
if ( wp_script_is('quicktags') ){
?>
<script type="text/javascript">
QTags.addButton( 'eg_h3', 'h3', '<h3>', '</h3>', 'h', 'Заголовок h3', 1 );
QTags.addButton( 'eg_hr', 'hr', '<hr />', '', 'h', 'Горизонтальная линия', 201 );
QTags.addButton( 'eg_pre', 'pre', '<pre lang="php">', '</pre>', 'q', 'Подсветка PHP синтаксиса', 111 );
</script>
<?php
function feedFilter($query) {
if ($query->is_feed) {
add_filter('the_content','feedContentFilter');
}
return $query;
}
add_filter('pre_get_posts','feedFilter');
function feedContentFilter($content) {
$content .= '<p>ЗДЕСЬ ПИШИТЕ ПРОИЗВОЛЬНЫЙ ТЕКСТ </p>';
return $content;
function fb_move_admin_bar() {
echo '
<style type="text/css">
body {
margin-top: -28px; padding-bottom: 28px;}
body.admin-bar #wphead {padding-top: 0;}
body.admin-bar #footer {padding-bottom: 28px;}
#wpadminbar {top: auto !important;bottom: 0;}
#wpadminbar .quicklinks .menupop ul {bottom: 28px;}
</style>';