Limit wordpress posts loop to continue onto another page - wordpress

Theres a site i did that on the home page, i created kind of like a news box type
of thing which is what the client wanted...
the posts bit im using to limit the posts on the index page is
query_posts('posts_per_page=4');
Now, this limits my posts to "4" or whatever number i want etc, when the user clicks on the
"news" page button, it takes them to a page which has the full posts loop without the
query_posts('posts_per_page=4'); which essentially shows them all the posts.
Now the problem is that, this person is posting A LOT now and the page now has a bunch of posts one after the other.
Is there a way to limit these to any number (that i choose) and show the rest of the posts on another page???
So essentially something that says
filter out 20 messages/excerpts for example, BUT after 20 show a "next" page or something like that?
is that possible? Because as it stands now, by years end this ONE page will have hundreds of posts.
ive looked around but not sure exactly what im looking for. This one came close (here on SO)
Wordpress loop show limit posts
And although its similar, i need a way to limit the posts on the page AND continue them on another page so that one page doesnt hold ALL the posts.
Thanks in advanced.

The homepage is controlled by index.php or a template file used by a page which you can set up to be your homepage at Settings > Reading.
You must check your index.php file or the template file used the page from the homepage.
If your queries in the code are not including any "posts per page" arguments, you can control this numbers from Settings > Reading.
There is also a plugin which can help you:
http://wordpress.org/extend/plugins/custom-post-limits/
Now, clicking on news page, you must check if that is a page or a category listing?
If it's a page, then it is handled by page.php or an attached/used template for it. Again, the code is important, how the queries are written. It it's a category listing, then the category.php is handling that page.
Pay attention for the template files are using each every page/post and learn this: http://codex.wordpress.org/Class_Reference/WP_Query
Good luck! :)

http://codex.wordpress.org/Settings_Reading_Screen
In the settings you can set a default max limit of how many posts per page.

Related

Permalink Goes to Old Page

I have been working on a site created by another developer. I have been fixing the site to make it more visually appealing. I am also responsible for adding new events and pictures which i self taught myself to do.
I have a situation where I have a page with the following permalink:
http://www.cic-nj.org/events/
The problem is that this link goes to a page that does not show the edits that i am making under that page and there is no other page listed that shows the info it actually displays.
this is what I have in the editor box on wordpress that I want it to show.
enter image description here
this is what appears when url is used or when i click view
enter image description here
I have been sure to click update and renewing page to view it. it's like its going to a ghost page i can not edit.
Can anyone point me in the right direction on this?
Thanks in advance...
You are experiencing "slug collision": more than one thing in your WP install has the same slug.
The problem that you have is events is a custom post type, with a slug set to events - therefore the url http://www.cic-nj.org/events/ is directing to the listing of events. This is an automatic feature of WordPress. (Note - you can see more details to support this conclusion by the fact that you've got individual events accessible at url's such as http://www.cic-nj.org/events/blue-apron-info-session/ )
Note that custom post type slugs will always take priority over a page / post slug.
You have a couple of options:
If you want a page to display the content that you've created, the page's slug / permalink must be different than events
If it's acceptable, you can rename the slug of the "events" custom post type to something different. This has the potential consequence of losing SEO "juice".
If it's acceptable, you can remove the custom post type, if you aren't going to use them any longer.
NOTE: It may be tempting to ask "how do I remove the custom post type", or "how do I change the post type slug". Those are different questions, and if you need to ask, they should be asked in a different question - not added as a comment below.

WP blog posts index URL

I want to use WP for a site that blog is just one aspect of it, and I don't want requests to home_url list blog posts (post_type=post), I want them be to fetched using another URL.
This topic default-archive-url-wordpress suggest two ways:
page_for_posts option
post_type=post URL query parameter
but I have questions
About the first, How a page would be able to loop into the posts, and where I should update this option (which hook)?
For the second, the guy says that using this param, make the wordpress get the archive for the specified post type, but I think posts don't have archive (according to includes/post.php their has_archive is left to default) how should I change this and also I want to use a permalink/pretty link for accessing posts.
Thanks in advance
Go to settings -> reading, and change the front page displays posts settings to front page displays a static page and then select a blog page.
Easy as pie.

WordPress: Showing posts by categories/tags on the index page

Is it possible to show posts by categories/tags on the index page instead of taking the user to the tag.php and category.php pages?
For example, when the user clicks the 'Uncategorized' category, I would like all the Uncategorized posts to replace the list of posts already there on the index page.
I've been trying to find out if anyone has done this but I've had no luck. I'd really appreciate it if someone could give me a link to somewhere that tells me how to go about doing this or lets me know how to change the code to get this to work.
This can be done. I can not recall a page that has done it but I do know it would require you creating your own custom page template.
http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates is a good place to start learning how the page templates are created.
Some additional links
http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
http://wordpress.org/support/topic/tag-archive-from-a-single-category-is-this-possible?replies=34

How to transfer Likes number on the second page of WP article when using pagnation?

I have a really popular WP blog but I want to increase number of "pageviews" by splitting my articles on two article pages by using code.
Everything works fine except the like button. On the second page of the article it's showing zero Likes and when you like the article on the second page it share the URL of the second page.
Permalink structure looks like this: http://www.tarzanija.com/article-title/ and second page of the article is http://www.tarzanija.com/article-title/2/
Is there any way I can set my Like button to show count and URL of the first article page on the /2/ page?
Since this is my first post here I hope I didn't do anything wrong :)
Cheers!
You need to explicitly set the og:url meta tag for both pages to be the same (http://www.tarzanija.com/article-title/).
For no matter which page of the article you're on, always use http://www.tarzanija.com/article-title/ in the like plugin's code. Don't insert the page number or it will be counted as separate likes by Facebook.

Post privacy in Wordpress

Can a post be hidden from home page, archive view, category lists etc. and viewable only if you have a direct link to it? The blog doesn't have registered readers and is open to public so that would be a mean of hiding some posts from public view without using the password protection.
I asked this question in Wordpress section and the idea there was to use conditional code so I'm asking the question here as well to get closer to the code.
If I used conditioning, would I have to input each post's ID separately to PHP file for archive, categories, search and such?
EDIT:
After reading a bit more all over, I had an idea of creating a private category and then use some kind of conditioning so that posts from that category are hidden. According to Codex, certain category can be hidden from, for example front page but I don't know if there's a way to hide it altogether except when you have a direct link.
Creating a "Private" category is a good solution. It is quite possible to hide this category altogether except via direct link. You just have to "block all the exits" with conditional code.
The default WordPress theme displays posts via the Post Loop. See http://codex.wordpress.org/The_Loop, especially the section entitled "Exclude Posts from Some Category". Just find all the places in your theme's PHP files (e.g. index.php) where this loop is used, and add the conditional code. You'd also need to filter your category list and blog archives in the side menu. Don't add filtering in single.php, otherwise the private post won't display on its own page.
You'd probably want to add a similar condition to filter search results so that private posts aren't leaked via the blog's search tool. There may be more "exits" I haven't thought of, but I'll be sure to update as I do. I'm glad to look at specific code if you so desire.
Understanding WordPress' post query and loop really opens up a world of possibilities for customization.
I found the simplest way - just use Simply Exclude Wordpress plugin. It has the option to exclude each post (or tag, for that matter) from front page, archive, search or feed. It works flawlessly. You can still view the posts by using direct links.
(Not actually an answer that includes code but a working solution nonetheless.)

Resources