- This topic is empty.
-
AuthorPosts
-
July 2, 2009 at 9:45 am #25336
kilmc
MemberI have been across the net trying to get a way to generate a list of posts posted by a specific author.
The site is for a band and I have a member page for each person in the band. I want to have a list of posts specific to the member come up just like wp_list_archives or something along those lines but I havn’t found anything useful in over 3 hours of searching and testing.Anyone know how to do this, I’d really appreciate it.
July 2, 2009 at 11:20 am #60065apostrophe
ParticipantSurely the simplest way of doing it is to assign each band member their own category and then have a list of posts in that category.
July 2, 2009 at 2:17 pm #60080TheDoc
MemberYou can actually accomplish this using the query_posts:
http://codex.wordpress.org/Template_Tag … Parameters
query_posts(‘author=XXX’)
July 2, 2009 at 6:57 pm #60092kilmc
Member@apostrophe I had been thinking of doing that
@TheDoc Could you paste in the exact code i need, I’d be using author ID 1. Its not lazyness its just that I tried the query posts before and got bad php errors. I’m not good with php yet so I don’t understand why things don’t workThanks for the help.
July 3, 2009 at 2:27 am #60131TheDoc
MemberYou did not read that link I posted my friend!
haha no worries, this is how a query_post should look in it’s most basic form:
Code:Basically, you have to make sure it comes BEFORE the loop, or else you’re hooped.
July 3, 2009 at 6:25 am #60129kilmc
MemberI had tried that code before but I got this error
Parse error: syntax error, unexpected ‘.’ in /home/chequeredmaniac/kosmonauts/wp-content/themes/kosmonauts/members.php on line 14
Tried it again just in case and I got the same thing.
I’ve tried placing the code both above and below the header. I’m using a custom page which doesn’t use the loop, or at least there no code there for it and there’s no template tag inserting it.Code:BIO
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin erat sem, euismod quis laoreet vel, aliquet id dolor. Vestibulum eget urna pretium felis posuere faucibus convallis in quam. Suspendisse turpis lectus, ullamcorper vitae malesuada fringilla, condimentum eu enim. Sed at ipsum eros, vitae auctor mi. Maecenas convallis dignissim lorem. Quisque eget diam felis. Nulla nisl diam, feugiat accumsan porttitor et, bibendum ornare sapien. Donec tincidunt nunc in ante lacinia rutrum. Fusce interdum nulla sit amet nisl tempus eu iaculis orci ultrices. Aenean egestas sodales urna at hendrerit. Sed vitae pharetra arcu. Maecenas et porta elit. Fusce rhoncus iaculis erat congue lobortis. Suspendisse posuere, sapien ac tempor iaculis, purus urna euismod libero, sit amet bibendum dui massa ac dolor.THE BASICS
full name: Kilian McMahon
age: 18
plays: Drums + Sings
influences- idiot pilot
- fall out boy
- reuben
- god is an astronaut
- motion city soundtrack
fave film: fight club/hackers
fave food: fried noodlesEQUIPMENT
kit 5 piece pearl export elx
cymbals- 14″ AA Metal-X Hi-Hats
- 16″ AA Metal-X Crash
- 22″ AA Metal-X Ride
- 18″ Vaults Crash
- 20″ Paragon China
ADD ME
twitter @kilmc
facebook Kilian McMahon
flickr Kilmc
vimeo Kilmc
myspace iAmDarknoise
bebo ChequeredManiacThat’s the page and all its code.
Could be something else causing they problem that you might spot.
July 3, 2009 at 12:44 pm #60144TheDoc
MemberYou can’t put in exactly what I’ve written.
If the page doesn’t have a loop, then it won’t show any posts. I was under the impression that the page already had a loop and was showing posts by all authors.
If you don’t know about the loop, I’m afraid you’re going to have to take a few steps back and figure that out before you start stepping into modifying it.
July 3, 2009 at 1:37 pm #60145kilmc
MemberI think it would be a whole lot easier if I just used categories. It removes a lot of hastle. If it’s a page its not going to have all the posts in the same way the index.php loop has. So I can’t see how even including the loop on a page will allow me to use query posts in the way I want to.
The categories method is definitlely suited to this project. I’m under time constraints but I may figure out a way of doing it in the future.
Thanks for all the help
July 3, 2009 at 2:07 pm #60148TheDoc
MemberI completely disagree.
You can use the WP loop anywhere, not just on an index page. If you’re going to show posts from a user, you’re going to have to use a loop, there’s no way around that.
To display posts from only one category, you’re still going to use query_posts.
July 4, 2009 at 10:04 am #60183kilmc
MemberI don’t think I actually explained this properly. I just want to display a list of links in a column of links that the member has posted. I don’t actually want the page displaying the posts. That’s not the purpose of that page.
So all I need are link of, say the 5 most recent, posts by that author.
July 4, 2009 at 4:00 pm #60194TheDoc
MemberOooohhhhhh I gotcha now.
Here ya go!
Code:get_results(“SELECT * FROM $wpdb->posts WHERE post_author = 1”);echo “Posts by Author 1”;
-
foreach ($numposts as $numpost) {
- “.$numpost->post_title.”
echo ““;
}?>
July 5, 2009 at 7:38 am #60216kilmc
MemberThats definitely on the right track however I am now getting a list of everything I have published as that author, like pages etc. I also seem to be getting revisions or comments because a lot of the post names are showing up multiple times. Is there a way to only query blog posts?
Finally I need them to be links. So where would I wrap an a tag to get this to happen? Or would it be more complicated than that.
I really appreciate all this help. I wouldn’t be able to do any of this without your help.
Kilian
July 5, 2009 at 12:50 pm #60261davesgonebananas
MemberThis is the code I use on a custom page template to achieve something similiar to what you are aiming for.
In order for this to work you have to assign the template to a page like normal. Then create a custom field called "author" and assign this a value of the author id whose posts you wish to appear.Code:Recent blog posts
ID, ‘author’, true)) :
query_posts(“author={$author}&post_status=publish&post_type=post&showposts=3”);
if ( have_posts() ) : ?>
This person doesn’t have a blog yet.
I really hope that this helps you. Please let me know how you get on.
July 5, 2009 at 4:46 pm #60249TheDoc
MemberJust stumbled across this, have you tried it?
July 5, 2009 at 5:54 pm #60241kilmc
Member@TheDoc, I had tried it, couldn’t get it to work.
@davesgonebananas Thank you so much. It is perfect, exactly what I wanted. I appreciate it so much. Let me know if I can help anytime, I’m a graphic designer. Just email me or @ reply me on twitter http://www.twitter.com/kilmc for any design stuff you need.Also thanks to TheDoc for all your help. Really appreciate it.
Wahoo, its fixed.
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.