Skip to content

Instantly share code, notes, and snippets.

View iiiBird's full-sized avatar
💭
Пока ты спишь - твой конкурент совершенствуется

iBird Rose iiiBird

💭
Пока ты спишь - твой конкурент совершенствуется
View GitHub Profile
@iiiBird
iiiBird / del-head.php
Last active August 29, 2015 14:16
Удалить лишнее из head
<?php
remove_action('wp_head','wp_enqueue_scripts');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
@iiiBird
iiiBird / add-widget.php
Last active August 29, 2015 14:16
Добавить Виджет
<?php
function true_register_wp_sidebars() {
/* В боковой колонке */
register_sidebar(
array(
'id' => 'true_side', // уникальный id
'name' => 'Боковая колонка', // название сайдбара
'description' => 'Перетащите сюда виджеты, чтобы добавить их в сайдбар.', // описание
'before_widget' => '<div id="%1$s" class="widjet %2$s">', // по умолчанию виджеты выводятся <li>-списком
@iiiBird
iiiBird / short-news.php
Last active August 29, 2015 14:16
Замена [...] в короткой новости
<?php
function new_excerpt_more( $more ) {
return '...';
}
add_filter('excerpt_more', 'new_excerpt_more');
@iiiBird
iiiBird / thumbnail.php
Last active August 29, 2015 14:16
Миниатюры
<?php
//Задать миниатюру в functions.php
if ( function_exists( 'add_theme_support' ) )
add_theme_support( 'post-thumbnails' );
add_image_size( 'lol-thumb', 700, 300, true ); //Жесткий обрезчик миниатюр
<?php the_post_thumbnail('lol-thumb');?> //Вывод
@iiiBird
iiiBird / cat-name.php
Last active August 29, 2015 14:16
Вывод названия категории
Категория: <?php foreach((get_the_category()) as $category) { echo '<a href="'.get_category_link($category->cat_ID).'" title="'.$category->cat_name.'">'.$category->cat_name.'</a> '; } ?>
@iiiBird
iiiBird / index.php
Last active August 29, 2015 14:16
Пример страницы натяжки
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-type" content="text/html; charset=<?php bloginfo('charset'); ?>">
<title><?php wp_title('«', true, 'right'); ?></title>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>> //Нужные классы в боди
@iiiBird
iiiBird / news.php
Last active August 29, 2015 14:16
Вывод новости
<?php
<div class="news">
<?php while ( have_posts() ) : the_post(); ?>
<div class="news-item is-post is-post-excerpt" <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<ul class="post-info">
<li>Категория: <?php foreach((get_the_category()) as $category) { echo '<a href="'.get_category_link($category->cat_ID).'" title="'.$category->cat_name.'">'.$category->cat_name.'</a> '; } ?></li>
<li><?php comments_number(); ?></li>
<li><?php echo get_the_date('F j, Y'); ?></li>
</ul>
<div class="post-img">
@iiiBird
iiiBird / scripts.php
Last active August 29, 2015 14:16
Подключить скрипты
<?php
function my_scripts_method() {
wp_deregister_script('jquery');
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js', false, false, true );
wp_register_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', false, false, true );
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'bootstrap');
}
add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
@iiiBird
iiiBird / css.php
Last active August 29, 2015 14:16
Подключить CSS
<?php
function my_style_method() {
wp_register_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
wp_register_style( 'styles', get_template_directory_uri() . '/css/styles.css' );
wp_enqueue_style( 'bootstrap');
wp_enqueue_style( 'styles' );
}
add_action( 'wp_enqueue_scripts', 'my_style_method' );
@iiiBird
iiiBird / short-news-length.php
Last active August 29, 2015 14:16
Длина короткой новости
<?php
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );