- This topic is empty.
-
AuthorPosts
-
March 27, 2011 at 9:18 am #32147MikaelHeinonenMember
Hi everyone.
I´m obviously a newbie both here and when it comes to PHP and wordpress. I got a site up and running with wordpress much thanks to the excellent tutorials provided by Chris. My problem is the following:
I have posts about authors (cat=7) and I would like to use the post title which is the author name as a condition to find posts in another category (cat=5) with a custom field named ‘Author’. From all posts that match I would then like to get some other custom fields (‘ISBN’, ‘Binding’ ‘Pris’, ‘Lagerstatus’ and ‘post-image’) so I can display that information in the sidebar. I´m thinking of putting it in some sort of slider.
I have not been able to find any information on how to set up such a condition, so any help or pointers in the right direction would be greatly appreciated.I´m including an image describing what I´m trying to do.
To the image describing the problem.March 27, 2011 at 3:21 pm #53491DogsGhostMemberCheck out Chris’s screencast #65, gives a good overview on custom fields. You should be able to adapt what he goes over there.
March 27, 2011 at 4:23 pm #53493MikaelHeinonenMemberHi.
I did actually watch that video really carefully in the hope of finding a way to do what I am trying to do. But, the way Chris does it with his recommended products would in my case result in a single.php that is about a mile long and it would require a lot of additional custom fields.
The thing is that I simply want single.php to recognize what the current title of the page is and match that against a custom field ‘Author’ which is not in this post but a different category of posts, so that I can pull out some custom field data from those posts. I would really rather not add a bunch of custom fields to the posts for this.
The title of the current page is an exact match to the content of the custom field ‘Author’ on all the relevant post so there is no chance that I would get anything that I don´t need.
I am currently looking at a way of doing this with tags which seem to work, but it would be much more elegant if it could be done using the current page title, since that would mean that I would not need to add any additional data.I have a feeling that this would be rather simple if I only knew enough php, but like I mentioned in my first post I am a total newbie when it comes to php. My description of the problem might even be more complicated than the solution.
April 14, 2011 at 4:27 pm #51178magnuseideMemberHi
I’ve been in almost the exact same situation when making a website for a publishing house, crosslinking book and author posts.You might be able to use this :
$args = array(
'numberposts'=> -1,
'post_type'=> 'post',
'cat' => 5,
'meta_key'=>'author',
'meta_value'=>get_the_title()
);
$books = get_posts($args);
echo '- ';
- ID).'" >'.get_the_title($book->ID).' ';
foreach ($books as $book):
echo '
endforeach;
echo '
?>
Tweak it with get_post_meta($book->ID, ‘metakey’, true) to recieve other meta data per post(book) you recive.
April 19, 2011 at 3:33 am #50470MikaelHeinonenMemberThank you magnuseide. That was exactly what I was looking for. It is working perfectly without any additional data.
June 19, 2011 at 10:23 am #81874jaffaMemberHi Guys
I am trying to do something similar but as the original poster I am new to both php and wordpress.
I have a number of pages about each team member, I would like to be able to match the title of the page (which is the team members name) to a custom field used in the posts.
I would then like to be able to display the latest 5 posts written by that team member.
Any idea’s?
Thanks
June 29, 2011 at 6:06 pm #82618jaffaMemberAfter modifying the code above I got it to work!
I am trying to add thumbnail images to the list though not having much luck. Is it possible?
-
AuthorPosts
- The forum ‘Back End’ is closed to new topics and replies.