Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ----------------------------------------------------------------------------------------------------
- [forqy-menu section_id="1"]
- ----------------------------------------------------------------------------------------------------
- */
- if ( ! function_exists( 'forqy_shortcode_menu' ) ) {
- function forqy_shortcode_menu( $atts, $content = null ) {
- // Type
- $type = 'menu';
- // Taxonomy
- $taxonomy = 'section';
- $atts = shortcode_atts(
- array(
- 'section_id' => '1',
- ),
- $atts
- );
- ?>
- <?php
- $count = 1;
- /**
- * Get Terms
- */
- $args = array(
- 'orderby' => 'none',
- 'order' => 'ASC',
- 'hide_empty' => 1,
- 'parent' => 0,
- 'include' => $atts['section_id']
- );
- $terms = get_terms( $taxonomy, $args );
- ?>
- <?php if ( $terms ) { ?>
- <?php foreach ( $terms as $term ) { ?>
- <?php
- /**
- * Terms Query
- */
- $args = array(
- 'post_type' => $type,
- 'tax_query' => array(
- array(
- 'taxonomy' => $taxonomy,
- 'terms' => $atts['section_id'],
- 'field' => 'term_id',
- 'include_children' => 0
- )
- ),
- );
- $query = new WP_Query( $args );
- ?>
- <section class="fy-term-item fy-term-item-<?php echo esc_attr( $count ); ?>">
- <header class="fy-term-header js-reveal-container">
- <h2 class="js-reveal"><?php echo apply_filters( 'translate_text', esc_attr( $term->name ) ); ?></h2>
- <?php if ( ! empty( $term->description ) ) { ?>
- <div class="fy-term-description js-reveal">
- <?php echo apply_filters( 'translate_text', wp_kses( $term->description, array(
- 'a' => array(
- 'href' => array(),
- 'target' => array()
- ),
- 'br' => array(),
- 'em' => array(),
- 'strong' => array()
- ) ) ); ?>
- </div>
- <?php } ?>
- </header>
- <?php if ( $query->have_posts() ) { ?>
- <div
- class="fy-flex-container fy-flex-container-stretch fy-flex-gutter-large js-reveal-container">
- <?php while ( $query->have_posts() ) { ?>
- <?php $query->the_post(); ?>
- <div
- class="fy-flex-column-33 fy-flex-column-tablet-100">
- <?php get_template_part( 'content', $type ); ?>
- </div>
- <?php } ?>
- </div>
- <?php } ?>
- <?php
- /**
- * Get Children
- */
- $args_children = array(
- 'taxonomy' => $taxonomy,
- 'child_of' => $atts['section_id'],
- 'order' => 'ASC',
- 'orderby' => 'date',
- );
- $children = get_terms( $args_children );
- ?>
- <?php foreach ( $children as $child ) { ?>
- <?php
- /**
- * Child Query
- */
- $args_child = array(
- 'post_type' => $type,
- 'tax_query' => array(
- array(
- 'taxonomy' => $taxonomy,
- 'terms' => $child->slug,
- 'field' => 'slug'
- )
- ),
- 'post_status' => 'publish',
- 'order' => 'ASC',
- 'orderby' => 'date',
- 'ignore_sticky_posts' => 1,
- 'posts_per_page' => - 1
- );
- $query_child = new WP_Query( $args_child );
- ?>
- <?php if ( $query_child->have_posts() ) { ?>
- <header class="fy-child-header">
- <h3 class="fy-padding-top-0"><?php echo apply_filters( 'translate_text', esc_attr( $child->name ) ); ?></h3>
- <?php if ( ! empty( $child->description ) ) { ?>
- <div class="fy-child-description">
- <?php echo apply_filters( 'translate_text', wp_kses( $child->description, array(
- 'a' => array(
- 'href' => array(),
- 'target' => array()
- ),
- 'br' => array(),
- 'em' => array(),
- 'strong' => array()
- ) ) ); ?>
- </div>
- <?php } ?>
- </header>
- <div class="fy-flex-container fy-flex-container-stretch fy-flex-gutter-large">
- <?php while ( $query_child->have_posts() ) { ?>
- <?php $query_child->the_post(); ?>
- <div
- class="<?php if ( is_active_sidebar( $type ) ) { ?> fy-flex-column-100 <?php } else { ?> fy-flex-column-50<?php } ?> fy-flex-column-tablet-100">
- <?php get_template_part( 'content', $type ); ?>
- </div>
- <?php } ?>
- </div>
- <?php } ?>
- <?php } ?>
- </section>
- <?php $count ++; ?>
- <?php } ?>
- <?php wp_reset_postdata(); ?>
- <?php } else { ?>
- <?php get_template_part( 'content', 'empty' ); ?>
- <?php } ?>
- <?php
- }
- add_shortcode( 'forqy-menu', 'forqy_shortcode_menu' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement