Im rebuilding a site I was working on using roots (wish I had spotted it to begin with)
the ‘portfolio’ page displays 6 portfolio items of around 15, (fussy client doesnt want the page to scroll up
im using the standard wp code
at the bottom of the portfolio page, but nothing displays, even though the div is there.
i dont know if its a theme thing or bootstrap so apologies if I am asking in the wrong place.
by single do you mean a one off page template?
this exact code worked on the site before and but it just doesnt display anything at all, even though the code is there.
i have been through the codex and tried each of those options but i just dont get any links to previous or next, - they are there, just not visible if that makes sense. - i cant seem to post code here either it doesn’t display for me?
The only important part of the code is the function that you are using, so I’ve edited the post to reflect that.
When I say single templates, I mean templates used to display a single post or page; as opposed to archives or indexes that loop through multiple entries.
If you use a single template to display an archive or index then you’ll need to make certain changes to the query or use a different function. The code from underscores is a good example of this; it uses the is_single conditional to check what kind of template is being used and alters the code accordingly.
With these kind of questions, it will usually help if you expand on how you have set up your data and/or provide your template code (with the loop).
Ive been at this a while, and this is as far as I have got. - this is now displaying a previous / next bar at the bottom, though i pinched this code from a previous site I made, its not the recommended way to display in columns as per the roots documentation ( I dont really know if its ok or not)
the only problem i have now, is its displaying the sidebar at the bottom. another issue again, but i have no idea where its getting it from.
all my problems are coming from the fact that my understanding of php and programming / scripting is very basic, something i am trying hard to rectify. http://pastebin.com/GAQFsVg1
it is definitely skipping out loads of code, that is there when I post it, even when I go back in to edit the post its all there.
and then on refresh its gone. I will look at that now. Just half of what I am reading is still whooshing over my head unfortunately.
Try to avoid query_posts. The reasons are explained very well at the beginning of the codex page.
One thing I forgot to add to the WP_Query example I posted last week was wp_reset_postdata(). I’m editing the post to add that now.
Try putting that after your endwhile in your first version. I suspect that might be causing the problem with the sidebar.
edit: i’ve finally experienced the code display bug take a look at the codex on wp_reset_postdata if you’re not sure how to use it
Im stuck then - if i follow that code in the codex the posts still display nicely but none of the pagination codes work, they just don’t output anything. - oh and the sidebar isnt there either then, but no next and last either.
ive tried edit 2 and no pagination appearing with that either, - the only way i get it is with the ‘naughty’ code.
and tried the
php wp resetpostdata (sorry cant type that as code)
but I still get a sidebar.
im beginning to think things just do what they want to trial me !
so im not sure which to do, try and stick with the one that works and try and get rid of the sidebar, or try to figure the one that doesn’t display any pagination.
ive also manually navigated to page two, and i do get a ‘newer’ link at the bottom of that page, but its still the same content, ie not an older set of posts.
Is there a specific reason you are using a page template rather than the built in archive template for that post type?
I’ve updated my gist with an example of how the archive-portfolio.php file could look like in your case as well as updated your roots_display_sidebar function to show how to disable it for the portfolio post type archive