Wordpress Category.php not showing all posts in that cateogry - wordpress

I am having an issue with my category showing all post from that category. My code is here: Category Loop
I have it set up to show my posts in 3 columns. You can see it in action here. There are like 48 posts that should show up, but for some reason I only get 10.
Any suggestions?

10 is the default value of the query variable posts_per_page. You use have_posts() and the internal Wordpress mechanisms to retrieve posts, hence you are limited by this number. You can change it like this:
query_posts( 'posts_per_page=50' );
See this page: http://codex.wordpress.org/Function_Reference/query_posts

Related

Combine Wordpress site search results with product search results on one page

On my Wordpress website, a site search that is limited to only posts renders a perfect results display of posts. A product search also renders a perfect display of products, although displayed differently. But if I attempt to search for both posts and products, the display is terrible. I think the products are probably forced into the posts display template. Since each of my products includes an explanation post inside the product description, those posts are repeated after every product -- mighty ugly. I don't need any product descriptions to be shown the results and prefer all products to be displayed like they are in the only product search.
This is all visible if you search for 'Grace' using the three different search inputs at this testing post: https://www.hebrewwordpics.com/dummypost/
I want to use only one search input form that will do both searches and display them together sequentially on one page.
Using WooCommerce and StoreFront child theme. Currently limiting searches with Ivory Search plugin, but the results are similar with other plugins or none at all.
You can use get_post_type() to identify which post type is being queried. Then display a specific template per post type.
get_post_type( int|WP_Post|null $post = null )
Retrieves the post type of the current post or of a given post.
Parameter
Description
$post
(int/WP_Post/null) (Optional) Post ID or post object. Default is global $post. Default value: null
You can use the following on your search page.
<?php
if ( 'post' === get_post_type() ):
// ... post template
elseif ( 'product' === get_post_type() ):
// ... product template
else:
// ... else
endif; ?>

WooCommerce Shop page : Customize sorting dropdown to product categories dropdown

I would like to modify the products sorting on the shop page to product categories filter where the user can select the browse the products of categories from there.
I am a rookie in programming. I checked the WooCommerce directory to find the .php file I should work on. I got some clue it is in archive-product.php but I don't see the code which display the sorting dropdown.
Can anyone give me some clue to achieve this ? Or is there any workaround ? Thanks.
I added this in functions.php :
// remove default sorting dropdown
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
// now add the new dropdown
add_action( 'woocommerce_before_shop_loop', 'add_product_category_dropdown' );
function add_product_category_dropdown(){
print '<span class="woocommerce-ordering">'; // So it takes the same position as the default dropdown
the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' );
print '</span>';
}
The reason you wouldn't see the code is that majority of what is generated by Woocommerce is handled by actions and hooks. In easier terms this means Woocommerce creates functions that spits out content and assigns them to different areas of the website.(For more information on Woocommerce actions and hooks, read here - https://docs.woothemes.com/document/introduction-to-hooks-actions-and-filters/ )
I'd recommend using the plugin below. It does exactly what you seem to be asking for and you can avoid having to play in parts you might not be comfortable with yet.
https://wordpress.org/plugins/yith-woocommerce-ajax-navigation/
Most awesome thing is that it's not one of those plugins that force you to get premium to actually get the desired effect.
I just found the solution few days ago. I use the function of WooCommerce product categories widget on the shop page.
This line of code will output the dropdown of product categories:
<?php the_widget( 'WC_Widget_Product_Categories', 'dropdown=1' ); ?>

Wordpress multiple / exclusive posting pages

I want a site with a separate News and Blog page, ie only news posts are dispayed on news pages and non news posts on blog pages. Also archive lists, category lists, etc for each page must only display relevant posts. Seems like a common requirement, but using the WP documentation, I keep going around in circles!!! Is there a simple way to do this, without getting into multiple blogs, eg using categories.
Thanks
That's easy.
First, you will need to create custom page template. Refer to this page to see how to create it.
Second, on that page (you can copy from your page.php/index.php, the important part is:
if (have_posts()) : while (have_posts()) : the_post();
Find that piece and add this code just right above that code:
query_posts('cat=3&paged='.get_query_var( 'paged' ));
Things to note from above query_posts snippet is:
cat: this is the category ID you want to query. To easily see what ID is on a particular category, you can use ShowID for Post/Page/Category/Tag/Comment plugin.
paged: Paged will allow your custom page to handle next & prev navigations, which is handled by next_post_link() and prev_post_link(). As for get_query_var( 'paged' ) is function to get what page's page you currently see.
Hope that helped.
<shamelessplug>
I blogged it here (in Bahasa Indonesia, which you can easily translate using google translate).
</shamelessplug>

Returning number of posts in Wordpress

I need a function to calculate the number of posts in a Wordpress blog that is aware if you are looking at a category, a given tag or the whole blog.
I'm keen to avoid rewriting for every different circumstance and want to make sure I get off on a reliable path. Relatively new to Wordpress any help appreciated.
Thanks
If you want to retrieve a count of all the posts in a blog, use wp_count_posts(). To get post counts from a specific category, do a count() on a call to get_posts() with the category ID specified as a parameter.
Example:
<?php
$posts = get_posts('category=1');
$count = count($posts);
echo $count;
?>
Unfortunately WordPress' wp_count_posts() function won't count a category's posts. It'll only count different post types, i.e posts, pages, drafts, and in 3.0, custom post types.
Provides a template function: WordPress › Count Posts « WordPress Plugins. Could borrow the code from it and integrate it into your theme's functions.php file.

Related posts from the blogosphere - dynamic integration of Google Blogsearch RSS on wordpress category pages

I'm looking for a method to put the three latest "news" from Google Blogsearch/Twitter search feeds into the bottom of category Pages. Maybe like this (assuming we're on the archive page for the "Sports" category):
What others say about "Sport":
Instapundit - Michael Jordan Comeback!
Huffington post - Michael Jordan Comeback!
Crazyguy - Michael Jordan Comeback!
So we all know that you can put
<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('pathtofeed.com', 3); ?>
in a template-file and it will list the latest three items of a feed.
I would like to put the path to the feed of a query to Google Blogsearch, e.g. [http://blogsearch.google.com/blogsearch_feeds?hl=en&q=sport&ie=utf-8&num=10&output=rss][1]
Works fine. But I would like to replace the sport query with the template tag for the category title - so it dynamically queries Google for a RSS-feed of sport searches. I've tried this:
<?php
include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('www.blogsearch.google.com/blogsearch_feeds?hl=en&q=<?php single_cat_title() ?>&ie=utf-8&num=10&output=rss', 3);
?>
(omitted 'http' cause I can't post hyperlinks here as a new user).
But all I get is:
There was a problem with the feed, try again later.
(translated from Danish error message).
Is it the syntax?
You've got a couple of issues in that code.
The first is you have a <?php inside an already opened <?php section. Concatenation is the answer to that problem.
The second is the function single_cat_title() displays the category title by default. Meaning it "echo()"s it out. So you need to tell that function to return the value not display it.
My solution would be to add a line of code above your include there to get the category you're looking for along the lines of:
$current_category = single_cat_title("", false);
The "false" tells the function to return it as a value instead of displaying it by default, the first parameter is the prefix or the text to display before the category title.
Then concatenate the current_category variable into your include statement
You can check out that function on the Template Tags page in the Wordpress Codex.

Resources