Removing pagination from Woocommerce product variations - wordpress

By default, from the edit product page, Woocommerce begins to paginate product variations once you have more than 20 for a single product. How can I remove this pagination, so that all product variations can be viewed at once from the edit screen, regardless of how many there are?

The previous answer is an absolute no-go. NEVER change plugin core files.
Please do the following:
add the following line in your functions.php (preferably in your child-theme folder too)
//Display 24 products on archive pages
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 24;' ), 20 );

I achieved it thus (my use-case was to remove pagination entirely):
add_filter('woocommerce_admin_meta_boxes_variations_per_page', function() {
return PHP_INT_MAX;
});

https://woocommerce.wordpress.com/2015/07/13/improving-the-variations-interface-in-2-4/
The pagination restricts editing and saving to 10 variations at a time. But you can change the amount using the woocommerce_admin_meta_boxes_variations_per_page filter if needed.
So, as per: https://www.thathandsomebeardedguy.com/increase-woocommerce-variations-per-page-in-the-admin-product-screen/ edit your functions.php and paste the snippet there.

By default WC set pagination as 15 variations but you can change it from below file
/wp-content/plugins/woocommerce/includes/admin/class-wc-admin-assets.php
line no 205
'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 15 ) )
Replace
'variations_per_page' => absint( apply_filters( 'woocommerce_admin_meta_boxes_variations_per_page', 1000 ) )

Related

Show content before main content based on color attribute

I found a code snippet to display the content before the main content and it worked.
Currently the content is displayed on all pages. (except shop page)
The code :
add_action( 'woocommerce_before_main_content', 'BannerShop', 35 );
function BannerShop(){
if(!is_shop()){
echo '<img src="https://localhost/demosite/wp-content/uploads/2015/06/512x356.png" >';
}
}
What I want to ask is, how to display content only for color attribute products in the form of links.
Example :
The display (content) will ONLY SHOW when the url is like this :
mysite.com/color/red/
Sorry if the explanation is not good because I don't really understand this.
Any help is greatly appreciated.
thank you
I understand your question is about displaying that extra content, if the current query is for a product archive page only showing products of a certain attribute 'color'.
Each WooCommerce attribute is an independent taxonomy.
WordPress's is_tax('parameter') function checks, if the query is for an existing custom taxonomy archive page (other than category & tag) & if the query is for that specific taxonomy 'parameter', in your case 'color'.
So, this code snippet in your functions.php or equivalent plugin should work:
add_action( 'woocommerce_before_main_content', 'BannerShop', 35 );
function BannerShop(){
(is_tax('color')) {
echo '<img src="https://localhost/demosite/wp-content/uploads/2015/06/512x356.png" >';
}
}
Though, to make the above template WooCommerce override work, declare WooCommerce support for your theme by adding the following lines to your functions.php or plugin equivalent:
function theme_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'theme_add_woocommerce_support' );

How do I apply this WordPress filter?

I need help to apply this WordPress filter...
apply_filters( ‘wcmp_widget_vendor_product_sales_report_days_range’, 7, $requestData, $vendor );
This filter is what has been provided to me by the plugin makers (WC Marketplace) - all they said was "in order to display product sold over 60 days, you have to do custom code. For this use this filter apply_filters( ‘wcmp_widget_vendor_product_sales_report_days_range’, 7, $requestData, $vendor ); and change the value change 7 to 60."
I am new to WordPress coding and am not sure how to go about applying this filter. The only reference to this filter in their plugins code is in this file https://github.com/dualcube/dc-woocommerce-multi-vendor/blob/master/classes/class-wcmp-ajax.php on line 2905.
Any help would be great. I have already looked in the WordPress references but I am clueless.
Use this code in your theme's functions.php file:
// To change the default value of `$days_range` from 7 days to 60 days
function lh_wcmp_vendor_custom_sales_report( $days_range ) {
$days_range = 60; // you can adjust days here as you needed
return $days_range;
}
add_filter( 'wcmp_widget_vendor_product_sales_report_days_range', 'lh_wcmp_vendor_custom_sales_report', 10 );
Though I don't have data to test it, but I am sure it will work for you.

How to add pagination on BBPRESS forums page?

I want to add pagination on forums pages after 10 forums list: http://nimb.ws/MEUyK2
Add this PHP function to your child themes functions.php file or in a plugin like functionality to increase the total amount of forums in the page. It may also be better to just show the Topics by Freshness in the forum root instead by setting it in Settings > Forums.
function rkk_increase_forum_per_page( $args ) {
$args['posts_per_page'] = get_option( '_bbp_forums_per_page', 150 );
return $args;
}
add_filter( 'bbp_before_has_forums_parse_args', 'rkk_increase_forum_per_page' );
Reference

Is there plugin for WP to show latest news with specific word in title or somewhere?

I need help with WordPress. For example, I have 100 posts in my blog, and only one post has a word: "HOT". I'd like to show this post on the right side (like widget). Can you advise me something?
There are plugins like "Recent Posts Widget Extended" that can filtered by tag or filter the post query on functions.php like :
add_filter( 'rpwe_default_query_arguments', 'your_custom_function' );
function your_custom_function( $args ) {
$args['s'] = 'HOT';
return $args;
}

WP Genesis Framework - Remove post_content and restructure entry

I'm creating a Wordpress theme with Genesis.
1.In homepage and archive page, I want display only featured image and post title. How could I remove post_content in hompage and archive page only. This link: http://my.studiopress.com/snippets/entry-content/ remove all content including when I view the post.
By default, Genesis display title -> post_info ->featured image -> post_content in the archive page. How could I restructure it. I would to display featured image fist ->title->post_info
Thanks
1. Hiding the Entry Content from Home & Archive Pages in Genesis:
You are on right track with entry_content hook via remove_action however as you want to happen it only on Homepage or Archive pages, you need to wrap that genesis code in WordPress's template tags i.e
<?php
if (is_front_page() || is_home() || is_archive() ) {
//* Remove the post content (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
}
?>
2. Changing the Order of Entry Parts in Genesis Framework
You can change order by changing Hooks or if hook is same then WordPress's hook priority value. Default value is 10 , higher the value, lower the hook placement.
For Example Entry Info and Entry Title are added this way:
add_action( 'genesis_entry_header', 'genesis_do_post_title' );
add_action( 'genesis_entry_header', 'genesis_post_info', 12 );
As you can see title's hook is default 10, and info is set to 12.
If I wanted to move post info up, I could simple remove title from 10, and add back at 14 e.g.
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
add_action( 'genesis_entry_header', 'genesis_do_post_title', 14 );
Now you can do change something from lower hook to above. Like in case of image, it is added at this hook:
add_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
As genesis_entry_content hook is way lower than genesis_entry_header, you can remove this image from here and move to genesis_entry_header or different hook e.g.
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_entry_header', 'genesis_do_post_image', 8 );
Above code removes Post image from the content section and then adds back to header section above the title.
See this visual guide for order of different genesis hooks: https://genesistutorials.com/visual-hook-guide/

Resources