ThemeShaper Forums » Thematic

[closed]

author.php x custom post types

(8 posts)
  • Started 3 years ago by iCristiano
  • Latest reply from em hr
  • This topic is resolved
  1. iCristiano
    Member

    Hi friends,

    I realized that the author´s page doesn´t list the custom post types, just the posts, right?
    Is there a simple way to hook it?

    Thanks!

    Posted 3 years ago #
  2. iCristiano
    Member

    I tryed the code below... It is almost working fine... it makes a loop in each post type and print all posts from that post type...

    The problem is that the query doesn´t respect the author=$authorID parameter and gets all posts from all authors...

    I tryed the query without the post types loop and the author=$authorID parameter works fine... so, I think the variable is been lost when the post type loop begins...

    Any help?? Thanks!!

    <div class="entry-content">
    <?php
    
    	$authorID = $authordata->ID;
    
    	$post_types=get_post_types();
    	foreach ($post_types as $post_type ) {
    
    		$query= 'author=' . $authorID. '&post_type=' . $post_type . '&orderby=post_date&order=desc'; // concatenate the query
     		query_posts($query); // run the query
    
    		if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    			<div id="artigos">
    
    				<div id="artigos_data"><?php the_time('j F'); ?></div>
    				<h2 class="artigo"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    				<div id="linha"></div>
    
    			</div>
    
    		<?php endwhile; else:
    
    		endif;
    
    	}
    
    	//Reset Query
    	wp_reset_query(); ?>
    
    </div>
    Posted 3 years ago #
  3. iCristiano
    Member

    Any help ???

    Posted 3 years ago #
  4. iCristiano
    Member

    I realized that the $authorID = $authordata->ID is getting no data here... the problem is with the $authordata->ID

    Posted 3 years ago #
  5. iCristiano
    Member

    Solved!

    I used this code to get the Author info:

    <?php if(isset($_GET['author_name'])) :
    	$curauth = get_user_by('slug', $author_name);
    else :
    	$curauth = get_userdata(intval($author));
    endif; ?>

    With that, I used it to get the user ID:
    <?php $authorID = $curauth->ID; ?>

    That is it!

    Posted 3 years ago #
  6. oc
    Member

    MAN, Thanks a million ...
    I spent days searching and trying to solve this problem with no solutions at all.
    I was trying to find why the stupid loop can't get the posts that is posted in custom post types? it seems there is still a problem with wordpress custom post types.

    anyway now the problem is fixed and I can get the author posts ... Thanks to you
    you rock ...

    Posted 3 years ago #
  7. educkf
    Member

    Hi!
    Thanks a million too! It almost fit what i needed!
    I just wanted to know if there is a way of showing just one type of custom-post-type, and exclude de regular posts. Lets say I wanted to show the "products" custom-post-type only.
    Can you help me, please? I tried a plenty of thing that didn't work.

    Posted 2 years ago #
  8. Hi

    Heads up changes to Thematic are coming that may affect you. This specifically has to do with how thematic will be handling custom post type archives and author archives.

    You might want to test the current build in the svn against your child theme mods.

    -Gene

    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.