Skip to content

Instantly share code, notes, and snippets.

View sxidsvit's full-sized avatar

Sergiy Antonyuk sxidsvit

View GitHub Profile
@sxidsvit
sxidsvit / functions.php
Created November 30, 2015 14:16
WordPress functions.php Must Have
show_admin_bar(false);
add_theme_support('post-thumbnails');
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'rsd_link' );
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
@sxidsvit
sxidsvit / post-thumbnail.html
Created November 30, 2015 14:18
WordPress Post Thumbnail URL
<?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' ); $url = $url['0']; ?>
@sxidsvit
sxidsvit / goals.js
Created November 30, 2015 14:20
Цели
//Цели для Яндекс.Метрики и Google Analytics
$(".count_element").on("click", (function() {
ga("send", "event", "goal", "goal");
yaCounterXXXXXXXX.reachGoal("goal");
return true;
}));
<?php
$idObj = get_category_by_slug('s_about');
$id = $idObj->term_id;
echo get_cat_name($id);
?>
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
echo '<p>Tag: <a href="' . get_tag_link( $tag->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $tag->name ) . '" ' . '>' . $tag->name.'</a> </p> ';
}
}
?>
<?php
$tags = wp_get_post_tags($post->ID);
<?php if ( have_posts() ) : query_posts('p=1');
while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; endif; wp_reset_query(); ?>
//In Template
<?php
$options = get_option('sample_theme_options');
echo $options['phone1'];
?>
//in functions.php
require_once ( get_stylesheet_directory() . '/theme-options.php' );
//theme-options.php file:
<?php
$post = $wp_query->post;
if (in_category('cat_label_1')) {
include(TEMPLATEPATH.'/single-cat_label_1.php');
} elseif (in_category('cat_label_2')) {
include(TEMPLATEPATH.'/single-cat_label_2.php');
}
?>
<?php
if ( have_posts() ) : // если имеются записи в блоге.
query_posts('cat=3'); // указываем ID рубрик, которые необходимо вывести.
while (have_posts()) : the_post(); // запускаем цикл обхода материалов блога
?>
<?php the_post_thumbnail(array(100, 100)); ?>
<? endwhile; // завершаем цикл.
endif;
/* Сбрасываем настройки цикла. Если ниже по коду будет идти еще один цикл, чтобы не было сбоя. */
wp_reset_query();
//functions.php
register_nav_menus(array(
'top_mnu' => 'Top Menu',
));
//Template
wp_nav_menu(array(
'theme_location' => 'top_mnu'
));