I set my front page as recent posts. But It display all the posts at front page.
I need to display only 5 recent posts at first page.
I like to have that "Continue reading" after 10 lines of the each post content.
Q1 - Controlling Amount Of Posts Displayed
Dashboard -> Settings -> Reading -> Blog pages show at most -> change to 5 -> Save Changes -> test
If that didn't work you may be using a custom theme which controls posts per page with a function. Check functions.php for something like if ( $query->is_front_page() and in that if statement may be something similar to $query->set( 'posts_per_page', '10' ); You will want to change 10 to 5.
Q2 - Controlling Post Excerpt Length
The easiest way if one has no experience working with wordpress template files is to add the <!--more--> tag in your post editor and wordpress will cut the post at exactly that spot. Here's some info about using it.
You will see on the above linked page the option to customize it with a function. It requires messing around with the template files a little. Leave a comment if you want to know more about that and I can try to help you with a better explanation.
Related
This may seem more like informational question rather than a coding question but I may be wrong.
Let's say I have a site, www.xyz.com. This site is built in wordpress from a custom template. (That I will put together).
The site will showcase products with each product being input through individual posts. SO techincally speaking, It's already using the "blog" feature of wordpress.
Now I want to add a blog into my site. Let's say www.xyz.com/blog/
I could create a custom page in my theme folder called
page-blog.php
in which that would work fine.
But here is were im stumped. I want to show blog posts here that are not found on the original xyz.com page. If I use the wordpress loop on the blog page, it will show all my posts that are on the xyz page. I want to show separate posts on my blog page then the ones I show on my main page.
So my main page would have lets say, a 1000 posts of products, each product being a different post.
For my blog, I want to run the loop but not show the products posts, but show regular "blog" posts, not products. Like information, etc, etc...
I'm stumped on how I can run the loop on the blog page and have it pull in different posts that are not on my main page. Would I have to install a separate wordpress installation? I believe this would be a major hit on site performance, and also caching would be more difficult i think.
So you have 'products' and you have 'posts'. Two different post types. See: https://wordpress.org/plugins/custom-post-type-ui/
Create a new Post Type for products.
Enhance your WordPress theme so it displays products differently. Note that some themes come equipped to handle custom post types automatically, while others may require you to make some minor adjustments or add additional template files.
Refer to the article at WordPress regarding Template Hierarchy.
See also: The Complete Guide to Custom Post Types
I understood your concern and I can say no need for extra WordPress setup and it is easily achived by creating category for example you can create category blog or product.
Now let's start with main site , if you want to show all post then nothing to do on that.
Secondly on blog you just need to get post having blog category, and this can be achieved easily by wp_query if you are writing your custom loop otherwise best way to use hook. You can use pre get post action as below,
function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '-1,-1347' ); } }
add_action( 'pre_get_posts', 'exclude_category' );
First of all, I'm not good at english. Sorry :( .
Hello! I'm developing woocommerce theme. And I meet problem. Please see this screenshot !.
When I Click The Return shop Btn -> browser request this query below!.
The query changed!!! from [~~?page_id=693] to [~~?post_type=product]
How This Can Happened??
And this is the shop page(id = 693) !...I'm so surprised! Please help me.
In your woocommerce settings you have assigned shop page(693). That's why that page 693 is behaving like a shop page, and it's permalink is [~~?post_type=product].
If you want to show all of a certain post type in your own page (template), copy archive.php and rename it as - 'archive-{your_post_type}.php'. This will load your post types only. Now change the template as per your need.
I would like my blog post pages (single.php) to include the normal blog page (index.php) below each post. Basically when you're in the archive and click on a blog post, it should appear as if the post simply gets inserted above all the posts:
index.php
1. Blog post 1
2. Blog post 2
3. Blog post 3
single.php
title
content
1. Blog post 1
2. Blog post 2
3. Blog post 3
I'm aware I can do my own get_posts() call and simply foreach all the posts, but seeing as I've already got my index.php styled and working fine, and I want that exact same template below every single post, it would be much easier for me if there was some sort of way to replicate "the loop" used on the archive page. I would also need it to work with the normal pagination (though it would point back to the archive).
<iframe>ing the index.php file would actually be exactly what I want - only you know, I obviously don't want to do that :P
Any ideas?
Unfortunately it isn't possible to do it the way you're thinking, because de WP main query is very different in these two cases (index and single). However you can use get_template_part function, that works just like an include, and put inside it the query that you want to replicate. Then you can call it in single.php, index.php, archive.php and so on.
It would be something like:
get_template_part('loop');
And inside loop.php you call a WP_Query with whatever you want.
Hope it helps!
I'd like to change the layout of the listing page of a business directory so that it looks similar to this layout, http://pastebin.com/1aHenCCN, using the same Wordpress theme.
I will modify single-listing.php page (at minimum)
Could someone help me with this? I know that I may need to pay for this.
listing page of all listing post type is archive-listing.php ,
Single page of individual listing post type is single-listing.php. So you need to modify archive-listing.php for to effect entire listing page.
Assume that listing is your post type .
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.