This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php echo getNumEnding(1, array('день', 'дня', 'дней')) ?> | |
<?php | |
/** | |
* Функция возвращает окончание для множественного числа слова на основании числа и массива окончаний | |
* param $number Integer Число на основе которого нужно сформировать окончание | |
* param $endingsArray Array Массив слов или окончаний для чисел (1, 4, 5), | |
* например array('яблоко', 'яблока', 'яблок') | |
* return String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('excerpt_more', function($more) { | |
return '...'; | |
}); | |
function new_excerpt_length($length) { | |
return 15; | |
} | |
add_filter('excerpt_length', 'new_excerpt_length'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Кнопочга вверх | |
$('.lift').click(function () { | |
$('body,html').animate({ | |
scrollTop: 0 | |
}, 400); | |
return false; | |
}); | |
$(window).scroll(function(event) {if ($(window).scrollTop() >250) { $('.lift').show()} else {$('.lift').hide()};}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Выдираем айди видео с ютуба | |
function parse_yturl($url) | |
{ | |
$pattern = '#^(?:https?://)?(?:www\.)?(?:youtu\.be/|youtube\.com(?:/embed/|/v/|/watch\?v=|/watch\?.+&v=))([\w-]{11})(?:.+)?$#x'; | |
preg_match($pattern, $url, $matches); | |
return (isset($matches[1])) ? $matches[1] : false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php global $post; $posts = get_posts( array('numberposts' => 5, 'post_type' => 'post') ); foreach($posts as $post){ setup_postdata($post); ?> | |
<?php } wp_reset_postdata(); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Кол-во постов в категории | |
function scf_get_category_count($taxonomy, $name) { | |
// Формируем запрос | |
$term_slug = $name; | |
$term = get_term_by('slug', $term_slug, $taxonomy); | |
// возвращаем данные | |
return $term->count; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Теги | |
*/ | |
get_header(); ?> | |
<div id="content"> | |
<?php if ( have_posts() ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version. | |
Do you ever wanted to be able to get tags related to one (or more) specific category? If yes, I’m pretty sure you’ll be delighted with this very cool tip. | |
First, here is the function you have to paste in your function.php file: | |
function get_category_tags($args) { | |
global $wpdb; | |
$tags = $wpdb->get_results | |
(" | |
SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Ссылка для запуска подгрузки постов --> | |
<a href="#" data-ajax="<?php echo get_option('siteurl').'/wp-admin/admin-ajax.php'; ?>" data-category="<?php echo get_query_var('cat'); ?>" data-offset="<?php echo get_option('posts_per_page'); ?>" data-perpage="<?php echo get_option('posts_per_page'); ?>" class="more-posts">Загрузить еще</a> | |
<!-- Скрипт отправки аякса --> | |
<script> | |
$('.more-posts').click(function(e) { | |
// обезоружим ссылку | |
e.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Показываем окошко, если пользователь еще не видел ее | |
function func() { | |
if (!localStorage.getItem("dshow")) { | |
$('.makepopuap').click(); | |
} | |
} | |
setTimeout(func, 1000); | |
// Если кликнули по закрытию - ставим метку и окно уже не показываем |
OlderNewer