Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

MUltiple loops inside author.php WordPress

I need the following to be placed inside author.php in the following order...

Display all the author's posts from the custom post type (AAAAAAA), then
Display all the author's posts from the custom post type (BBBBBBB), then
Display the author's user meta from their profile, then
List all the author's normal posts from the author, then
List all the author's posts from the custom post type (CCCCCCC)

In effect this is 5 loops inside the author.php page. Ideally I can delete/ cut-out any loop without it affecting the other loops.

Points to note...
I want all the code to have closed php tags e.g
This...
<?php blah blah ?>
<p>something here</p>
<?php ?>

Not this...
<?php blah; { ?>
echo "<p>something here</p>";
<?php } ;?>


Some handy links...
[[LINK href="http://wordpress.stackexchange.com/questions/203499/display-custom-post-type-posts-first-then-default-posts"]]http://wordpress.stackexchange.com/questions/203499/display-custom-post-type-posts-first-then-default-posts[[/LINK]]
[[LINK href="http://wordpress.stackexchange.com/questions/72203/multiple-loops-in-same-page-without-duplicate-content"]]http://wordpress.stackexchange.com/questions/72203/multiple-loops-in-same-page-without-duplicate-content[[/LINK]]

Answers (3)

2015-10-21
2015-10-21

Andrea P answers:

definitely agree with Sebastien.

you're asking for a big chunk of code here, not just for suggestions.
could you raise the budget please?

and also, do you already have a sample html/php of how you want to display the posts inside these loops? or do you just need the query and loop and a sample displaying like
<p><?php the_title() ?></p>
within the loop

2015-10-21

Rempty answers:

I think the better solution is create 5 indepentent loops. You can get the author id with this code (inside author.php)

$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
$authorid=$curauth->id;

With this id you can create a custom query for each post type.
Example:

<?php
$args=array('author'=>$authorid,'post_type'=>'product');
$cquery=new WP_Query($args);
if($cquery->have_posts()):
while($cquery->have_posts()):
$cquery->the_post();
?>
<p><?php the_title();?></p>
<?
endwhile;
endif;
?>