Skip to content

Instantly share code, notes, and snippets.

View nikola0203's full-sized avatar

Nikola Milosevic nikola0203

  • SEO 1 Click
  • Belgrade, Serbia
View GitHub Profile
@nikola0203
nikola0203 / functions.php
Created July 13, 2017 08:23 — forked from gagimilicevic/functions.php
Detect RTL on website
function wp_is_rtl( $locale = '' ) {
static $rtl_locales = array(
'ar' => 'Arabic',
'ary' => 'Moroccan Arabic',
'azb' => 'South Azerbaijani',
'fa_IR' => 'Persian',
'haz' => 'Hazaragi',
'he_IL' => 'Hebrew',
'ps' => 'Pashto',
'ug_CN' => 'Uighur',
@nikola0203
nikola0203 / repeater-loop-even-number.php
Last active March 6, 2018 11:45
Repeater field ACF count in while loop even and odd number and display in different order.
<?php
if( have_rows('repeater_field') ):
$postCount = 1;
while( have_rows('repeater_field') ) : the_row(); ?>
<?php
$repeater_sub_field_1 = get_sub_field('repeater_sub_field_1');
$repeater_sub_field_2 = get_sub_field('repeater_sub_field_2');
$repeater_sub_field_3 = get_sub_field('repeater_sub_field_3');
@nikola0203
nikola0203 / list-categories.php
Last active April 24, 2017 14:47
List WordPress parent and child categories, if parent have childern display dropdown othervise clickable link.
<ul class="sidebar-menu">
<?php
$parent_terms = get_terms( 'product_cat', array( 'hide_empty' => false, 'parent' => 0 ) );
foreach( $parent_terms as $parent_term ) {
// display top level term name
$child_terms = get_terms( 'product_cat', array( 'hide_empty' => false, 'parent' => $parent_term->term_id ) );
?>
<li class="cat-item <?php if ($child_terms) { echo "have-children"; } ?>"><a href="<?php echo get_term_link($parent_term); ?>"><?php echo $parent_term->name; ?></a>
<?php if ($child_terms) : ?>
<ul class="children">