• Resolved Rose

    (@eos-rose)


    Is there a way to modify this code so that the title list displays in two columns? Preferably not a method that depends on CSS.

    function list_posts_by_taxonomy( $post_type, $taxonomy, $get_terms_args = array('exclude' => array(4, 15, 17, 18, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 86, 87, 88, 89)), $wp_query_args = array() ){
    	$tax_terms = get_terms( $taxonomy, $get_terms_args );
    
    	if( $tax_terms ){
    		foreach( $tax_terms  as $tax_term ){
    			$query_args = array(
    			'post_type' => $post_type,
    			"$taxonomy" => $tax_term->slug,
    			'post_status' => 'publish',
    			'posts_per_page' => -1,
    			'orderby'=> 'name',
    			'order' => 'ASC',
    			'ignore_sticky_posts' => true
    			);
    			$query_args = wp_parse_args( $wp_query_args, $query_args );
    
    			$my_query = new WP_Query( $query_args );
    			if( $my_query->have_posts() ) {
    				?>
    
    				<h2 id="<?php echo $tax_term->slug; ?>" class="tax_term-heading"><?php echo $tax_term->name; ?></h2>
    				<ol class="taxonomy-list">
    				<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    				<?php if(strpos(get_the_title(), 'Anthology') === false) { ?>
    					<li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    					<?php $terms = get_the_terms( $post->ID , 'series' );
    					if($terms) {
    						foreach( $terms as $term ) {
    							if ( $term->description !== '' )  {
    								echo '(' . $term->description . ') ';
    							}
    						}
    					}
    					?>
    					</li>
    					<?php } ?>
    				<?php endwhile; ?>
    				</ol>
    				<?php
    			}
    			wp_reset_query();
    		}
    	}
    }

    I tried modifying this code, but I can’t seem to get it too work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Michael

    (@alchymyth)

    all column formatting, particular if you are working with an ordered html list, depends on css.

    Thread Starter Rose

    (@eos-rose)

    I don’t necessarily need an ordered html list. The two columns are what counts and the link I included indicates that it *is* possible to do what I need without depending on css.

    When I say I don’t want to depend on css, I mean that I don’t want to, for example, do something like adding even/odd classes to <li> and work with a bunch of blocks.

    What I hope to do is have the list split into two divs (as with the code I linked above) and do very simple css to make the columns display side-by-side.

    I perhaps worded my desires poorly. I’m not opposed to using css entirely.

    Thread Starter Rose

    (@eos-rose)

    Nevermind. I’ve found an alternative way to achieve the desired results. 🙂

    Cool Ella, glad you found a solution!

    Can you post your results?

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

The topic ‘Display query output in two columns?’ is closed to new replies.