Skip to content

Instantly share code, notes, and snippets.

View Trovin's full-sized avatar
🌴

Ruslan Kulyhin Trovin

🌴
View GitHub Profile
@Trovin
Trovin / Wp filter custom post+custom tax, by category id + load more
Last active September 27, 2019 10:20
Wp filter custom post+custom tax, by category id + load more
DON'T FORGET **
- change to your value $image, setPostType(), html response tpl, html classes
- hide by deffault in css 'page-stories__item'
IN YOUR TEMPLATE
================
<!-- get all custom taxonomy categories -->
<div class="stories-category__wrapper">
@Trovin
Trovin / JS animatie el on scroll
Last active July 31, 2019 14:53
JS animate el on scroll
function animateEl(animEl) {
let counter = 0.2,
animArray = animEl;
animArray.each(function(index, value) {
counter += 0.2;
$(value).css('transition-delay', `${counter}s`);
let targetPos = $(value).offset().top,
winHeight = $(window).height(),
@Trovin
Trovin / SVG encoding to right displayed (or use svg plugin SVG Support)
Last active September 12, 2019 10:48
SVG encoding to right displayed (or use svg plugin SVG Support)
<?xml version="1.0" encoding="UTF-8"?>
@Trovin
Trovin / WP cropping post content text
Last active July 31, 2019 15:11
WP cropping post content text
IN FUNCTION.PHP
===============
<?php
/**
* Add post filter characters.
*/
function content_excerpt( $args = '' ){
global $post;
@Trovin
Trovin / JS check active section on sticky menu
Last active July 31, 2019 15:07
JS check active section on sticky menu
//check active section
function activeSection() {
var flag = $('.page-header').hasClass('page-header_sticky');
if(flag) {
var links = $('.main-nav__link');
links.each(function(key,value) {
var newVal = $(value).attr('href');
var headerHeight = parseInt($('.page-header').height());
var currentSection = $(newVal);
@Trovin
Trovin / JS sticky menu
Last active July 31, 2019 15:07
JS sticky menu
//init sticky menu
function stickyMenu() {
var winScrollTop = $(this).scrollTop();
var element = $('.page-header');
if(element) {
if(winScrollTop >= 1) {
element.addClass('page-header_sticky')
} else {
element.removeClass('page-header_sticky')
@Trovin
Trovin / WP add classes to main-menu links
Last active July 31, 2019 15:05
WP add classes to main-menu links
@Trovin
Trovin / JS redirect & anchor scroll
Last active July 31, 2019 15:05
JS redirect & anchor scroll
//redirect & anchor scroll
var host = window.location.hostname;
function anchorRedirect() {
var pathToBlogPage = '/blog/#to-blog';
var pathToNewsPage = '/blog/#to-news';
var anchorItemBlog = $('.js-link_blog');
var anchorLinkBlog = $('.js-link_blog').find('a');
@Trovin
Trovin / JS dropped adaptive menu
Last active October 1, 2019 14:35
JS dropped adaptive menu
JS CODE
=======
// First we get the viewport height and we multiple it by 1% to get a value for a vh unit
let vh = window.innerHeight * 0.01;
// Then we set the value in the --vh custom property to the root of the document
document.documentElement.style.setProperty('--vh', `${vh}px`);
//init menu
let menu = {
@Trovin
Trovin / WP add class to primary menu item
Last active July 31, 2019 15:03
WP add class to primary menu item
IN FUNCTIONS.PHP
----------------
/**
* Add class to primary menu item.
*/
function atg_menu_classes($classes, $item, $args) {
if($args->theme_location == 'menu-1') {
$classes[] = 'main-nav__item';
}