Skip to content

Instantly share code, notes, and snippets.

View ihorduchenko's full-sized avatar
💭
Working

Ihor Duchenko ihorduchenko

💭
Working
View GitHub Profile
@ihorduchenko
ihorduchenko / Stylesheets using Javascript
Created January 18, 2017 21:02
Load stylesheets using Javascript
<!-- Load CSS -->
<script>
function loadCSS(hf) {
var ms = document.createElement("link");
ms.rel = "stylesheet";
ms.href = hf;
document.getElementsByTagName("head")[0].appendChild(ms);
}
loadCSS("css/fonts.css"); //User Styles: Fonts
loadCSS("css/style.css"); //User Styles: Main
<?php if( have_rows('slider') ): ?>
<?php while( have_rows('slider') ): the_row();
// vars
$image = get_sub_field('image');
$heading = get_sub_field('heading');
$disclaimer = get_sub_field('title');
?>
<div class="tables">
<div class="tables-col ac">
<?php if ( have_posts() ) : query_posts( 'cat=4'); while (have_posts()) : the_post(); ?>
<div class="table <?php $tag = get_field('tag');
echo $tag?>">
<div class="swiper-container gallery-top">
<div class="swiper-wrapper">
<?php if (have_rows('imgs')): ?>
//insert this code after #END WordPress
<FilesMatch "^.*(error_log|wp-config\.php|php.ini|\.[hH][tT][aApP].*)$">
Order allow,deny
Deny from all
</FilesMatch>
OR
<Files wp-config.php>
@ihorduchenko
ihorduchenko / functions.php
Created April 1, 2017 13:21 — forked from agragregra/functions.php
WordPress functions.php Must Have
show_admin_bar(false);
add_theme_support('post-thumbnails');
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'rsd_link' );
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
@ihorduchenko
ihorduchenko / jquery-active.js
Created April 1, 2017 13:27 — forked from agragregra/jquery-active.js
jQuery Active Menu
//Active menu
$("li a").each(function() {
if (this.href == window.location.href) {
$(this).addClass("active");
}
});
@ihorduchenko
ihorduchenko / Amount of flex-items per row
Last active April 13, 2024 14:06
How to adjust the amount of flex-items per row
@mixin max-width($width) {
@media screen and (max-width: $width) {
@content;
}
}
.container {
position: relative;
display: flex;
flex-flow: row wrap;
//destination file: functions.php
add_action('template_redirect', 'single_result');
function single_result() {
if (is_search()) {
global $wp_query;
if ($wp_query->post_count == 1) {
wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
}
}
}
@ihorduchenko
ihorduchenko / types.liquid
Last active September 5, 2017 06:04
Output list of products types for certain collection
{% if collection %}
<ul>
{% assign typeList = '' %}
<!-- if we have a collection, then we don't need to access it through collections... -->
{% for product in collection.all_products %}
{% capture type %}{{product.type}}{% endcapture %}
<!-- using 'unless' instead of 'if () do nothing else do something' -->
{% unless typeList contains type %}
<li>{{ product.type | link_to_type }}</li>
{% capture temp %}{{typeList}}{{product.type}}{% endcapture %}
@ihorduchenko
ihorduchenko / while-loop
Created April 25, 2017 08:36
Cross-browser loop using table
$query = new WP_Query( $args );
if ( $query->have_posts() ) { ?>
<table>
<?php $i = 0;
while( $query->have_posts() ) {
$query->the_post(); ?>
<?php if($i == 0){ echo "<tr>"; }?>
<td class="item_post_man">
<a href="<?php echo get_permalink(); ?>">
<?php if ( has_post_thumbnail() ) {