WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type Conversion (2 posts)

  1. polymaze
    Member
    Posted 2 years ago #

    Can anyone help with how to use this with a custom post type?

    $cat_args = array(
    			'orderby' => 'name',
    			'order' => 'ASC'
    		);
    		$categories = get_categories($cat_args);
    
    		foreach($categories as $category) {
    
    			$args = array(
    					'category' => $category->term_id
    			);
    			$posts = get_posts($args);
    
    			if ($posts) {
    
    				echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
    
    				foreach($posts as $post) {
    					setup_postdata($post); ?>
    					<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
    					<?php
    				} // END foreach ($posts)
    			} // END if ($posts)
    		} // END foreach($categories)
  2. polymaze
    Member
    Posted 2 years ago #

    Anyone have a suggestion for this? Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic