Skip to content

Instantly share code, notes, and snippets.

<?php
$current = $wp_query->get_queried_object();
// return the ID of the current term
// i.e. ID of term "Photoshop" is "26", so we get "26" if we are viewing "Photoshop"
$current_term_id = $current->term_id;
// return the nicename of the current term
// i.e. returns "Photoshop"
<?php
$taxonomyName = "types";
//This gets top layer terms only. This is done by setting parent to 0.
$parent_terms = get_terms( $taxonomyName, array( 'parent' => 0, 'orderby' => 'slug', 'hide_empty' => false ) );
echo '<ul>';
foreach ( $parent_terms as $pterm ) {
//Get the Child terms
$terms = get_terms( $taxonomyName, array( 'parent' => $pterm->term_id, 'orderby' => 'slug', 'hide_empty' => false ) );
foreach ( $terms as $term ) {
<?php // Get the taxonomy's terms
$terms = get_terms(
array(
'taxonomy' => 'types',
'hide_empty' => false,
'parent' => 0,
)
);
?>
<?php
$taxonomies = get_terms( array(
'taxonomy' => 'types',
'hide_empty' => false
) );
if ( !empty($taxonomies) ) :
$output = '<select>';
foreach( $taxonomies as $category ) {
function wpd_subcategory_template( $template ) {
$cat = get_queried_object();
if( 0 < $cat->category_parent )
$template = locate_template( 'category-child.php' );
return $template;
}
add_filter( 'category_template', 'wpd_subcategory_template' );
// Slide toggle
var linkToggle = document.querySelectorAll(".js-toggle");
for (i = 0; i < linkToggle.length; i++) {
linkToggle[i].addEventListener("click", function (event) {
event.preventDefault();
var container = document.getElementById(this.dataset.container);
<?php
$hero = get_field('testy', 'option');
if( $hero ): ?>
<?php echo $hero['inner']; ?>
<?php endif; ?>
<?php
$cta = get_field('testy', 'option');
if( !empty( $cta ) ): ?>
<?php the_field('testy', 'option'); ?>
<?php endif; ?>
<?php
// check if the repeater field has rows of data
if( have_rows('gallery') ):
// loop through the rows of data
while ( have_rows('gallery') ) : the_row();
// display a sub field value
?>
<section class="relative home-hero">
<div class="glide__track" data-glide-el="track">
<ul class="glide__slides">