Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Template Name: Customers
*/
// WP_Query arguments
$args = array (
'post_type' => 'customer',
'post_status' => 'publish',
'pagination' => true,
<div class="hdr">Российские Кабеленесущие Системы это:</div>
<div class="info-items">
<a class="item" href="#">
<div class="num">1</div>
<div class="txt">Выполнение заказа от 3-х дней</div>
</a>
<a class="item" href="#">
<div class="num">2</div>
<div class="txt">Разумная цена</div>
</a>
function os_rewrite_rules(){
$options = get_option( 'os_ub_settings', array( 'os_ub_text_slug' => 'company' ) );
$slug = $options['os_ub_text_slug'];
$cat_slug = $options['os_ub_cat_slug'];
add_rewrite_rule('^'.$slug.'/add/?','index.php?page_id=os_ub_add_page','top');
// dev
// flush_rewrite_rules( true );
<?php
if ( false === ( $vip_loop = get_transient( 'last_vips' ) ) ) {
$args = array(
'posts_per_page' => 100, // берем либо все посты, либо какое-то большое число
// по желанию отключаем лишнее
// 'no_found_rows' => true,
// 'cache_results' => false,
// 'update_post_term_cache' => false,
// 'update_post_meta_cache' => false,
@Dimasmagadan
Dimasmagadan / functions.php
Last active December 31, 2017 13:04
«Поделиться» в соцсетях. #WordPress
<?php
/* подключаем скрипт */
function os_ya_like_script() {
wp_enqueue_script( 'yashare', '//yandex.st/share/share.js', null, '1', true );
}
add_action( 'wp_enqueue_scripts', 'os_ya_like_script' );
@Dimasmagadan
Dimasmagadan / script.js
Created January 24, 2014 14:27
jQuery for WordPress
(function( $ ) {
"use strict";
$(function() {
$(document).ready(function(){
// тут код
});
// а тут плагин
});
@Dimasmagadan
Dimasmagadan / .htaccess
Last active December 31, 2017 13:00
Rewrite for wp-content\uploads folder.To stop searching for images while working on local machine.Code to override site URL to work locally. #WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [L]
</IfModule>
@Dimasmagadan
Dimasmagadan / os-spam.php
Created December 12, 2013 09:48
Quick&simple anti-spam for WordPress
<?php
/*
Plugin Name: OS Spam Comments Filter
Description: antispam
Author: dimas@odminstudios.ru
Version: 1.1
*/
function verify_comment_meta_data( $commentdata ) {
@Dimasmagadan
Dimasmagadan / functions.php
Last active December 27, 2015 10:59
Yandex social share
// добавить этот код в functions.php
function os_styles_and_scripts() {
if(!is_admin()){
wp_enqueue_script( 'yashare', '//yandex.st/share/share.js', null, '1', true );
}
}
add_action( 'wp_enqueue_scripts', 'os_styles_and_scripts' );
function os_my_link_shortcode( $atts ) {
extract( shortcode_atts(
array(
'link' => '',
), $atts )
);
if(is_user_logged_in()){
$out=$link;
} else {