Skip to content

Instantly share code, notes, and snippets.

View yuriitaran's full-sized avatar

Yurii Taran yuriitaran

View GitHub Profile
<?php the_post_thumbnail( 'large', ['alt' => get_the_title()] ); ; ?>
/* functions.php */
// Create pagination
function foundation_pagination( $query = '' ) {
if ( empty( $query ) ) {
global $wp_query;
$query = $wp_query;
}
// required for static front-page pagination
if ( get_query_var('paged') ) {
@yuriitaran
yuriitaran / wp-query-ref.php
Created November 7, 2017 10:08 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@yuriitaran
yuriitaran / WP: ACF repeater loop
Last active November 15, 2017 08:33
ACF repeater loop
// For Post Type
<?php $the_query = new WP_Query( array( 'post_type' => 'contacts', 'order' => 'ASC', ) );
if ( $the_query->have_posts() ) : ?>
<ul class="footer-contacts">
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<?php if( have_rows('contact_types') ): ?>
<?php while( have_rows('contact_types') ): the_row(); ?>
<li>
<?php if (get_sub_field('contact_type')): ?>
<span class="contact-title"><?php the_sub_field('contact_type'); ?></span>
@yuriitaran
yuriitaran / JQuery Starter functions
Last active November 9, 2017 14:45
JQuery Starter functions for WP theme
// Hide outline for all links
$('a').on('mousedown', function(){
$(this).css('outline', 'none');
});
// Scroll to Main content
$( '.scroll-to-content' ).click(function() {
$('html, body').animate({
scrollTop: ($('main').first().offset().top)
},800);
@yuriitaran
yuriitaran / WP: Display Post Tags ordered by ID
Created November 10, 2017 09:24
WP: Display Post Tags ordered by ID
// Display Post Tags ordered by ID
function show_post_tags_ordered_by_id($post_id) {
$args = array(
'orderby' => 'term_id',
);
$tags = wp_get_post_tags( $post_id, $args );
$html = '<div class="tags">';
foreach ( $tags as $tag ) {
$tag_link = get_tag_link( $tag->term_id );
@yuriitaran
yuriitaran / HTML: Disable Skype phone number link in Edge
Last active November 15, 2017 08:31
Disable Skype phone number link in Edge
@yuriitaran
yuriitaran / PHP: Reg_exp examples | preg_match | regexp
Last active March 11, 2018 08:37
Reg_exp examples /preg_match / regexp
// clean phone number for link "tel:1234567"
preg_replace("#(?<=\d)[\s-]+(?=\d)#","", $number)
// phone number
preg_match('/^\+[0-9\-\s]*(\([0-9]+\))?[0-9\-\s]*$/', $number)
// email
preg_match("/[0-9a-z]+@[a-z.]/", $email)
// phone number with WP ACF
@yuriitaran
yuriitaran / WP: Check for active dynamic Sidebar
Created November 20, 2017 15:01
Check for active dynamic Sidebar
<!-- BEGIN of page content -->
<div class="<?php echo ( is_dynamic_sidebar('right') ) ? 'large-8 medium-8' : 'large-12 medium-12'; ?> small-12 columns">
bla-bla-bla ...
</div>
<!-- END of page content -->
<!-- BEGIN of sidebar -->
<?php if ( is_dynamic_sidebar('right') ): ?>
<div class="large-4 medium-4 small-12 columns sidebar">
<?php get_sidebar('right'); ?>