Need help on linking customizer section to loop query
-
I created a post category selection in the wordpress customizer and working fine. I create a loop and link the the theme_mod to it but my challenge now is that the two are not contenting together. I want an instance where one for an example select politics category out of the numerous category lists in the customizer. it should only display thus.
Hep me look at my work and amend as necessary. I am a newbie in wordpres development
$categories = get_categories(); $blog_cat = array(); $i = 0; $blog_cat[]='Select'; foreach($categories as $category){ if($i==0){ $default = $category->slug; $i++; } $blog_cat[$category->slug] = $category->name; } // Featured Blog Posts. $wp_customize->add_setting( 'blogger_buzz_featured_blog', array( 'sanitize_callback' => 'sanitize_text_field', //done )); $wp_customize->add_control( 'blogger_buzz_featured_blog', array( 'label' => esc_html__( 'Select Category', 'blogger-buzz' ), 'section' => 'iraje_product_featured_catalog', 'choices' => $blog_cat, 'type' => 'select', )); function iraje_featured_product_loop(){ $featured_blog = get_theme_mod('blogger_buzz_featured_blog'); $featured_cat = explode(',', $featured_blog); $pr_count = get_theme_mod('iraje_product_column_layout',4); $pr_count = 12 / $pr_count; ?> <?php if (get_theme_mod('iraje_frontpage_product_display',true)==1){ ?> <div class="container"> <?php while ( have_posts() ) : the_post(); ?> <?php $args = array( 'post_type' => 'post', 'posts_per_page' => - 1, ); $q = new WP_Query( $args ); ?> <div class="row"> <?php while ( $q->have_posts() ) : $q->the_post(); ?> <div class="col-sm-6 col-md-6 col-lg-3 col-xl-3"> <h3> <a>"> <h2><?php the_title(); ?></h2> </a> </h3> <?php the_excerpt(); ?> </div> <?php endwhile; ?> <?php wp_reset_postdata(); ?> </div> <?php endwhile; ?> </div> <?php } ?> <?php }
add_action(‘iraje_featured_product_loop’, ‘iraje_featured_product_loop’, 100);
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Need help on linking customizer section to loop query’ is closed to new replies.