Pagination, Not sure what to do
-
I have set my page up like this. Perhaps it sucks in terms of code layout, but it’s working great.
Website:
https://www.jamestrusler.co.ukCode:
https://jamestrusler.co.uk/wp-content/themes/jamestrusler/helpMe.txtI have been struggling to add a pagination feature.
In the code I have written “<!–PAGINATE THESE–>” At that point, can anyone tell me what must be done to paginate those posts. I want to not show more than 5 posts within those loops. and have something like page 1 out of 3.
I have been trying for ultra long now.
Thanks in advance.
-
Glad to hear that you’ve negotiated this particualr bump. ??
vtx.. before I look at your page, Ill ask:
what does that do: wp_title(”,false,”);
I have got this… But tbh, It’s going over my head. I wish I didn’t suck so much.
$page_title = wp_title('',false,''); if( in_array($page_title, $pageNames) ) : query_posts('category=3,4,5,6&posts_per_page=1'); while (have_posts()) : the_post();?> <div class = "leftSideWrap"> <h2><?php the_title(); echo " <small>"; the_time(get_option('date_format')); ?></small></h2> <div class = "top"></div> <div class = "middle"> <div class = "cornerImage"></div> <?php the_content(); ?> <div class = "commentSeperateLine dotted main"></div><br /> <p> <a href="<?php comments_link(); ?>"> Add / View Comments to this post</a> - <?php comments_number('There are currently no comments', 'There is 1 comment', 'There are % Responses' ); ?> </p> </div> <div class = "bottom"></div> </div> <?php endwhile; endif; ?><?php posts_nav_link(); ?>
P.S I have no idea what a bump is. P.S, what? lol
P.S
I have put that function in my functions.php that vtxyzzy supplied.
Added the code from the <head></head> part of the header.php, I am seeing some next and back buttons. lovely lovely but I get this:
Warning: Cannot modify header information – headers already sent by (output started at /customers/jamestrusler.co.uk/jamestrusler.co.uk/httpd.www/wp-content/themes/jamestrusler/functions.php:36) in /customers/jamestrusler.co.uk/jamestrusler.co.uk/httpd.www/wp-includes/pluggable.php on line 868
When I press the next page button.. hmmm.
Ok,
This is my current code.
You may be thinking, why has he not listened to our posts.
I have, I have run through them.
I’m not quite grasping them.
current code:
https://wordpress.pastebin.com/p4vvDNak
current site:
https://www.jamestrusler.co.ukWhat I thought my code is doing is:
1. If the page is blog, get posts from the category id I specify.
2. While there is posts for that category, for each one, display the content. And when you reach the limit (1), then stop outputting.
3. After you done all the for each ones, Stop the while loop. Then display a link to another page that displays the remaining archived posts for that category.The problem is, I cannot comprehend just how it all works.
Warning: Cannot modify header information
You’ve got a leading or trailing blank line in one of your files – possibly functions.php.
Solving “headers already sent” warnings
(Oh – and I meant “bump” as in hitting and then getting over a bump on the road to getting your theme up & running ?? )
firstly, you’re a genius. You must have absored the wordpress codex.
It’s kind of unnatural.
Secondly, the phrase “bump” is worse than the “cowboy” phrase. ^_^
Thirdly.. And this is the exciting part:
Is now returning some junk with the current code.
https://wordpress.pastebin.com/Ta5341Tu
Unfortunately, the code has gone well out of my range. I havent just bummed out on it, I really read it and don’t understand it :S.
What’s your radar picking up esmi. I wish I could understand this stuff. It’s using the stuff vtx had recommended.. literally because it is the closest I have been.
I wonder what the wordcount is for “stuff” in this post ^_^
P.S
I see a pattern.. Its posting one comment from each section.. *reads over code*… *squeezes brain juice out*
Can you describe the problem a little more? I can’t see any pagination on your site, so I don’t have a clue what is wrong.
The code has changed completely since I last looked at it. Which bit is outputting junk?
Ok, here is my site at the moment:
https://www.jamestrusler.co.ukwith the code (search for “if ($mypages)”):
https://wordpress.pastebin.com/6BgM1NvgI had to change it to its working state before because I didn’t want the site to be down all day. So here it is, in non-functioning state.
this is what i want:
I want a loop that says:
if the page is blog, display posts i associate with blog page.
if there is more than 5 posts on the blog page, create a link at bottom that says goto next page of blog posts.In summary, it would be an archive. I only want the blog / poetry / picture / music page to display maximum of 5 posts, if there are more, I want them to archive.
I thought this was called pagination.
What you were seeing earlier was this (search for “/*IF PAGE IS ONE OF ARRAY PAGENAMES*/”):
https://wordpress.pastebin.com/kqrr1EN5
This code has no pagination but works great. If you would like to see this code in action then please just say.
I’m really stuck on what to do :S .
I see the problem: the last page links are not formed properly for some reason. Please post your functions.php to the pastebin so I can take a look.
Sorry for the trouble.
functions code:
https://wordpress.pastebin.com/N1WDfwabPlease dont say sorry. You are all working your ass of and im so happy you’re all helping. Thanks for your trouble.
Side note: The posts showing do not only belong to do blog page, it is showing 1 post from each category. I need it to display blog posts on blog page, poetry posts on poetry page.. etc.
You can see from my array at top of page which category belongs to which page:
$i = 3; $pageNames[$i++] = "blog"; $pageNames[$i++] = "music"; $pageNames[$i++] = "poetry"; $pageNames[$i++] = "pictures";
No, I really am sorry – I had only used that function on pages other than the home page, and it works there. I will rework and post a revised version.
Question: does the ‘Music’ page use a template? It seems to direct to index.php.
As for the posts not showing on the correct page, I will leave that for later.
every part of the website comes from the index page.
The working version originally went through my array at the top and just output posts which I assigned to categories I made.
Is that the info you needed?
OK – I think that I posted a link to an older version of the code. Please replace that function with the one found here.
Done.
Now i need to show blog posts on blog page, poetry posts on poetry page etc.
Is there any way I can help?
Looks like the pagination is working now. Can you post an updated copy of the index.php?
I suspect the problem with showing all posts is due to the use of index.php for all categories with no way for the template to tell which category it was called for. Once I have a look at the latest code, I may be able to tell more.
- The topic ‘Pagination, Not sure what to do’ is closed to new replies.