please make sure that the PageOfPosts template uses the same html structure as your theme;
the example in the codex was for the former default theme ‘kubrick’ and will not match most other themes.
@alchymyth: I updated that Codex section early yesterday to incorporate a simplified PageofPosts template based on Twenty Eleven. There is a warning about modifying the markup to suit your theme in there too. π
Ok, well I got the code for Graphene (the theme I’m using) here:
http://pastebin.com/jUyuGmtK
The way I was “calling” the categories before was from a custom field called ‘category’ which I don’t see in the code now. How exactly do I designate which category I want it to retrieve?
which I don’t see in the code now
That code is still there – just a little further down that Codex page.
Hmm, I guess I just don’t see it. I was looking for something similar to:
$category = get_post_meta($posts[0]->ID, 'category', true);
The closest I found on this new one is:
'category__in' => $cat,
Maybe I’m just missing it?
@esmi
re:
@alchymyth: I updated that Codex section early yesterday to incorporate a simplified PageofPosts template based on Twenty Eleven. There is a warning about modifying the markup to suit your theme in there too. π
I know π I saw one of your replies yesterday, mentioning it – therefore I worded my reply here ‘the example in the codex was for ….’
(the moderated code in the first post of this topic here contained the ‘kubrick’ formatting…)
Alchymyth,
It looks like you were the one who pasted that code for Graphene. Are you able to direct me how I can call a specific category using the code you provided and Custom Fields? I am unable to figure out where in the code I am able to do this.
Thanks.
it might help, if you could post a link to the problem page(s);
are you sure about the page IDs used in the conditional statements at the start of your page template?
are you aware that you could use page slugs as well?
if you want to use custom fields, try to replace line 11 to 17 of the pastebin with:
$category = get_post_meta($posts[0]->ID, 'category', true);
$cat = array();
if( $category ) { $cat = array(get_cat_ID($category)); }
the custom field with the key ‘category’ would need to contain the category name.
It’s not so much anything with the webpage in particular, more just of me not understanding how to use a Custom Field for ‘category’ using that code from pastebin. I did try what you suggested, and it seems like what I’m trying to accomplish, but didn’t quite work when I replaced the code.
I ended up getting this error:
Fatal error: Call to a member function have_posts() on a non-object in /hermes/bosweb/web041/b415/ipg.beatsbybroscom/wp-content/themes/graphene/pageofposts2.php on line 26
The first bit of my code looks like this:
http://pastebin.com/HLQxx1Ts
try to add a opening php tag at the start of line 11:
<?php $category = get_post_meta($posts[0]->ID, 'category', true);
(my mistake – I should have said: replace line 12 to … π
Ok, yes that works after changing line 15 from:
$showposts = -1; // -1 shows all posts
to
$showposts = 8; // -1 shows all posts
I was trying to set it up for 8 posts per page. Also, with “-1” nothing displayed on the page.
Just one more thing now that I’ve just noticed, the bottom of the page doesn’t show a ‘Previous Posts’ or ‘Older Posts’ link to look at anything before this list of most recent posts. Is there a way that I can add this?
Sorry for all the questions that keep coming up.
FYI, here is my entire code:
http://pastebin.com/J9svSptC
This topic is very helpfull, I have the same problem and this explains a lot! So thanks!
Just one question: where do I find the code I need for my theme (Twenty Ten Child)?
Thanks so much!