ThemeShaper Forums » Thematic

[closed]

author page sort by category

(5 posts)
  • Started 9 years ago by jrobben
  • Latest reply from jrobben
  • This topic is resolved
  1. Hi I am trying to use some code from http://www.cozmoslabs.com/2009/10/28/create-an-about-the-author-area-for-thematic/

    to display a custom author page

    got it to sort of work but having problems echoing the url
    tried all sorts of ' " and / combos but no luck

    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    
    here is what I am doing
    
    //The Loop
    	while ( have_posts() ) : the_post() ;?>
      <?php
    foreach ( get_the_category() as $category ) {
      //  echo $category->cat_name . ' '; for testing
     //  echo 'true ';
     //	echo	$cat_name;
    }
    ?>
    
    <?php  if ($category->cat_name == $cat_name)  {
    
    echo '<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>'
    ;
     }
    
     else { echo ' not true '; } // for testing
     ?>
    				<?php endwhile;
    				echo '';
     				//Reset Query
    				wp_reset_query();
    			}
     ?>
    </div>
    Posted 9 years ago #
  2. Got the page to display only links to the authors post in each category.
    The continue statement is what made it work. Left to do -Still would like the category names to be skipped if there are no posts by the author in that category. See it here
    http://www.rradvice.com/author/admin

    <?php //thematic_author_loop() - we won't use the default thematic author loop
    	  //instead will list the post sorted by category
    			$categories = get_categories();
    
    			foreach($categories as $category){
    				$cat_id = $category->cat_ID;
    				$cat_slug = $category->category_nicename;
    				$cat_name = $category->cat_name;
    
    				//The Query
    				query_posts(array(
    					'category__in'=>	$cat_id,
    					'author' =>			$authordata->ID,
    					'posts_per_page'=>	100
    					));
    				if(have_posts()){
    						echo '<h2>' . $cat_name . '</h2>';
        				}
    
    				echo '<ul>';
    				//The Loop
    				while ( have_posts() ) : the_post() ;?>
      <?php
    foreach ( get_the_category() as $category ) {
       // echo $category->cat_name . ' ';
       //  echo 'true ';
    //	echo	$cat_name;
    }
    ?>
    
    <!-- add back got right post test here -->
    
        <?php  if ($category->cat_name != $cat_name) {
            continue;} // skip a record
    ?>
    <!-- Display the Title as a link to the Post's permalink. -->
    <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    
    <!-- to test for post outside of category if ($category->cat_name != $cat_name) echo 'not true' -->
    
    </li>
    
    				<?php endwhile;
    				echo '</ul>';
    
    				//Reset Query
    				wp_reset_query();
    			}
     ?>
    </div>
    Posted 9 years ago #
  3. Ideally, Child Category II header would not print out. I plan to use this eventually on a site with a lot of categories and any given author may only have articles in a couple of categories. So I do not want a lot of empty category headers.

    Any ideas on this?

    Posted 9 years ago #
  4. Sorry this is a better example of the problem
    author Abby has one post listed in category plugin
    http://www.rradvice.com/author/abby

    Posted 9 years ago #
  5. I finally figured out my solution. Basically changed where in the loops the category was printing out then set a variable to test if the category had been printed.

    Here it is in action:
    a post in every category - http://www.rradvice.com/author/admin
    A post in only a couple of categories - http://www.rradvice.com/author/abby

    <?php  if ($category->cat_name != $cat_name) {
            continue;} // skip a record - DO NOT PRINT POST TITLE IF POST IS IN A DIFFERENT CATEGORY
    ?>
      <?php    if(!$executed) { // do once then reset $executed to false after all posts in category
      echo '<h3>' . $cat_name . '</h3>';
     $executed = true;
         }
    	 ?>
    
    <!-- Display the Title as a link to the Post's permalink. -->
    <p>
    <li> <a>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    </p>
    
    <?php endwhile; //END LOOP B
    echo '';
    $executed=false;	// RESET CATEGORY SO NEXT CATEGORY HEADING WITH POSTS WILL PRINTOUT
    	//Reset Query
    	wp_reset_query();
    			}
    Posted 9 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.