• Resolved amiable93

    (@amiable93)


    I have this code and i want to achieve it in the shortcode builder. Everything is fine except the thing where I have to choose the terms instead of taking them dynamically.

    Thats my code. Any idea? Is it something I have to do in Custom Arguments?

    <?php  $numbfour=0; $terms = get_terms( $taxonomyName, array( 'parent' => $custom_term->term_id, 'orderby' => 'slug', 'hide_empty' => false ) ); ?>
    <?php foreach ( $terms as $term ) { ?>
    <div  class="tab-pane fade  <?php if($numbfour == 0){echo 'in active';} ?>" id="subcategory<?php echo $numbfour.$numbtwo;?>" >
     <div id="posts">				
    	<?php $prds=new WP_Query(array(                       
    		'post_type' => 'products',
    		'orderby' => 'date',
    		'order' => 'ASC',
    		'posts_per_page' => 6 ,
    		'tax_query' => array(
    		    array(
    			'taxonomy' => 'product_categories',
    			'terms'    => $term ->term_id,
    			'field' => 'ID'                  
    		)))); ?>
    		
    		<?php $productnumb=1; if($prds->have_posts() ): ?> 
    		<?php while ($prds->have_posts()) : $prds->the_post(); ?>
    			<div class="col-md-4 prd-col">
    			<div class="overlay-wrapper">
    				<a href="<?php echo get_permalink(); ?>">
    					<?php the_post_thumbnail(); ?>
    				</a>    
    			       <a href="<?php echo get_permalink(); ?>">  
                                  <div class="prd-overlay">
    		            <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
    	                    </div>
    			</a>   		
    		</div>		
    	<a href="<?php echo get_permalink(); ?>"><h1><?php the_title(); ?></h1></a>					
    	<p><?php echo wp_trim_words( get_the_content(), 8, '...' ); ?></p>
    	<div class="descr-border"> </div>           		
    	<div class="front-more"> 
    	<h3>
            <a href="<?php echo get_permalink(); ?>"> Περισσότερα </a>
           </h3>
    	</div>            		
    	</div> 	
    																		
           <?php $productnumb++; endwhile;  endif;?>
    																		
    	</div>
    	</div>			                   					                   		
    				<?php $numbfour++; } ?>		
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @amiable93,
    Having a hard tim eunderstsnding the issue by looking at the code snippet. What is it exactly you are trying to do?

    Is it for a taxonomy archive page?

    Thread Starter amiable93

    (@amiable93)

    I am having some tabs and I query products based on the categories they belong.

    
    <?php foreach ( $terms as $term ) { ?>
    <?php $prds=new WP_Query(array(                       
    		'post_type' => 'products',
    		'orderby' => 'date',
    		'order' => 'ASC',
    		'posts_per_page' => 6 ,
    		'tax_query' => array(
    		    array(
    			'taxonomy' => 'product_categories',
    			'terms'    => $term ->term_id,
    			'field' => 'ID'                  
    		)))); ?>
    <?php } ?>

    But the categories are not specific they are coming from this

    <?php $terms = get_terms( $taxonomyName, array( 'parent' => $custom_term->term_id, 'orderby' => 'slug', 'hide_empty' => false ) ); ?>

    My only problem is that i recreate the whole thing in the shortcode builder except the time when I reach this and I have to select the terms instead of having them somehow dynamicaly generated like in the query above.

    To make it short.
    In that one [ajax_load_more post_type=”post” taxonomy=”product_categories” taxonomy_terms=”plotter-product-house” taxonomy_operator=”IN”]
    Can I make it to this one? [ajax_load_more post_type=”post” taxonomy=”product_categories” taxonomy_terms=”TERM_ID” taxonomy_operator=”IN”]

    • This reply was modified 9 years, 6 months ago by amiable93.
    Plugin Author Darren Cooney

    (@dcooney)

    You can pass dynamic values to the shortcode by using it your templates.

    You can see in this example, you can pass data from your page template to Ajax Load More.
    https://connekthq.com/plugins/ajax-load-more/examples/relationship-field/#code

    Is this what you are looking for?

    Thread Starter amiable93

    (@amiable93)

    Yes thank you a lot 🙂

    Plugin Author Darren Cooney

    (@dcooney)

    Ok perfect! Good luck, hope it works out for you.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Dynamic Taxonomy Terms in Shortcode Builder’ is closed to new replies.