Skip to content

Instantly share code, notes, and snippets.

@iraarx
iraarx / functions.php
Last active January 22, 2019 10:51
Сustom menu with BEM classes in WordPress (in functions.php)
*-------------- Creating custom menu with BEM classes :) ----------------*/
// Change main menu parameters
add_filter( 'wp_nav_menu_args', 'filter_wp_menu_args' );
function filter_wp_menu_args( $args ) {
if ( $args['theme_location'] === 'header-menu' || 'blog-menu' ) {
$args['container'] = false;
$args['items_wrap'] = '<ul class="%2$s">%3$s</ul>';
$args['menu_class'] = 'menu__list';
}
@iraarx
iraarx / functions.php
Last active January 22, 2019 09:39
Register post type, WordPress (in functions.php)
/*--------------- Register post type --------------------*/
function create_post_type() {
//Register post type Team
register_post_type( 'team',
array(
'labels' => array(
'name' => __( 'Team' ),
'singular_name' => __( 'Team-member' ),
'add_new' => __('Add team-member'),
),
@iraarx
iraarx / functions.php
Created January 22, 2019 09:41
Filter for Invisible tag -more- in posts, WordPress
/*---------------invisible tag -more- link text in posts----------------*/
add_filter( 'the_content_more_link', '__return_empty_string' );
@iraarx
iraarx / front-page.php
Last active January 28, 2019 15:13
WordPress Slider with Default Gallery and owl.carousel.js
<!-- hero-slider-->
<section class="hero-slider">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); // start if and while ?>
<!--code for slider images -->
<div class="hero-slider__images owl-carousel">
<?php if ( get_post_gallery() ) :
$gallery = get_post_gallery( get_the_ID(), false );?>
<!-- Loop through all the image and output them one by one -->
<?php foreach( $gallery['src'] as $src ) : ?>
<div class="hero-slider__item item" style="background-image: url(<?php echo $src;?>);"></div>
@iraarx
iraarx / template-home.php
Last active January 28, 2019 10:34
Simple WordPress Loop
<?php
/*
Template Name: Home
*/
?>
<!-- header -->
<?php get_header(); ?>
<!-- loop with litle and content -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); // start if and while ?>
@iraarx
iraarx / mixin.round-line-border.scss
Created February 16, 2019 13:47 — forked from cipas/mixin.round-line-border.scss
Sass mixin - round line border
@mixin circle($width, $border-width, $color) {
width: $width;
height: $width;
border: $border-width solid $color;
-webkit-border-radius: $width/2;
-moz-border-radius: $width/2;
border-radius: $width/2;
}
@iraarx
iraarx / template-home.php
Created February 24, 2019 12:23
WP_Query example
<section class="team" id="team">
<div class="row">
<?php $args = array (
'post_type' => 'team',
'posts_per_page' => -1,
'order' => 'ASC'
);
$team_query = new WP_Query( $args ); ?>
@iraarx
iraarx / template-home.php
Created February 24, 2019 15:54
WordPress Acf repeater example for icon with text block (used foundation grid)
<?php if( have_rows('features_block_list') ): ?>
<div class="row">
<?php while( have_rows('features_block_list') ): the_row();
// vars
$icon = get_sub_field('features_block_icon');
$title = get_sub_field('features_block_title');
$text = get_sub_field('features_block_text');?>
<div class="column medium-6 large-3">
<div class="features__item icon-with-text">
@iraarx
iraarx / template-home.php
Last active February 24, 2019 15:57
WordPress ACF repeater example social icons links list
<div class="photo-with-text__social-icons social-icons">
<?php if( have_rows('team_social_links') ): ?>
<ul class="social-icons__list">
<?php while( have_rows('team_social_links') ): the_row();
// vars
$icon = get_sub_field('social_icon');
$link = get_sub_field('social_link');?>
<?php
if( $link ):
$link_url = $link['url'];
@iraarx
iraarx / functions.php
Created February 25, 2019 19:20 — forked from kisildev/functions.php
ACF Google Map
<?php
// Load scripts and styles
function add_scripts_and_styles() {
if ( ! is_admin() ) {
// For styles
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style.css', null, null );
// For scripts (js)
wp_enqueue_script('jquery');
wp_enqueue_script( 'main-js', get_template_directory_uri() . '/js/main.js', null, null, true );
// Map