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_action( 'template_redirect', 'rider_redirect_canonical' ); | |
function rider_redirect_canonical(){ | |
if ( is_single() && ('post' === get_post_type()) ) { | |
$tax = 'category'; | |
// проверяем наличие терминов, иначе редирект бессмысленный | |
if ( $terms = get_the_terms(get_the_ID(), $tax) ) { |
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
window.onReadyState = (e, t) => { | |
const a = ["loading", "interactive", "complete"], | |
o = a.slice(a.indexOf(e)), | |
n = () => o.includes(document.readyState); | |
n() ? t() : document.addEventListener("readystatechange", (() => n() && t())) | |
} | |
window.onReadyState("complete",function(){(function(m,e,t,r,i,k,a)..... }) | |
////////////////////////////////////////// | |
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
//ACF Filter | |
<?php $GLOBALS['my_query_filters'] = array( | |
'field_1' => 'city', | |
'field_2' => 'vac' | |
); | |
add_action('pre_get_posts', 'my_pre_get_posts', 10, 1); | |
function my_pre_get_posts( $query ) { |
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 | |
// вывод дочерних рубрик и их записей на странице родительской рубрики | |
$parent_id = get_query_var('cat'); ?> | |
<?php | |
$sub_cats = get_categories( array( | |
'child_of' => $parent_id, | |
'hide_empty' => 0 |
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
Проблема актуальна, можно решать таким образом: | |
<div class="top-menu" data-hover="hover-on-menu"> | |
<a href="/to/your/url" data-hover="hover-on-link">Hello</a> | |
<script> | |
var touchHover = function() { | |
$('[data-hover]').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
/* | |
* Paste into the end <head> | |
*/ | |
(function(){ | |
var width = screen.width; | |
var oldViewport = document.querySelector('meta[name="viewport"]'); | |
var viewport = document.createElement('meta'); | |
viewport.setAttribute('name', 'viewport'); | |
viewport.setAttribute('content', 'width=' + (width <= 640 ? '640' : 'device-width')); | |
document.head.replaceChild(viewport, oldViewport); |
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 | |
/** | |
* Move WooCommerce subcategory list items into | |
* their own <ul> separate from the product <ul>. | |
*/ | |
add_action( 'init', 'move_subcat_lis' ); | |
function move_subcat_lis() { | |
// Remove the subcat <li>s from the old location. |
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
<button class="open-modal-btn" data-target="modal">open modal</button> | |
<div class="modal" id="modal"> | |
<div class="modal-inner"> | |
<button type="button" class="close-modal-btn">×</button> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Placeat ducimus tempora deserunt repellat architecto adipisci. </p> | |
</div> | |
</div> |
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 | |
add_action('wp_ajax_infinite_scroll_home', 'infinite_scroll_home', 0); | |
add_action('wp_ajax_nopriv_infinite_scroll_home', 'infinite_scroll_home'); | |
function infinite_scroll_home() { | |
$exclude_posts_json = $_POST['exclude_posts']; | |
$exclude_posts = json_decode($exclude_posts_json); | |
$post_offset = $_POST['post_offset']; | |
$infinite_scroll_args = array( 'post_type'=>'post', 'posts_per_page'=> 2,'post__not_in' => $exclude_posts, 'offset' => $post_offset); | |
$infinite_scroll_query = new WP_Query( $infinite_scroll_args ); | |
while( $infinite_scroll_query->have_posts() ) : $infinite_scroll_query->the_post(); |