How to add pagination on BBPRESS forums page? - wordpress

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

Related

how to remove "added-to-cart notice" from every page except product archive pages?

Note: In looking for an answer to my question I came across this post but it is NOT duplicate: Remove add to cart notice and change "add to cart" button in Woocommerce the answer there gives the option to remove the notice from the entire site. I want to remove it only from the cart page and I don't want to do it with CSS.
I use external links to my site to send people directly to the shopping cart with the item already added to the cart. When doing so, the "added-to-cart notification" shows up on the cart page which I do not want.
I found this code which removes the added-to-cart notification: add_filter( 'wc_add_to_cart_message_html', '__return_false' ); but it removes the notification from all pages of my site which is not what I want.
To be more specific, I want the added-to-cart notification to show on every product archive page and nowhere else.
I tried to add a filter but it doesn't work the way I would expect it to, I tried the following two ways (and tested it with various pages to see if I could make anything work but it seems my general syntax is off because I Can't get it to do anything...
function hide_cart_notes() {
if ( ! is_archive() ) {
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
}
add_action( 'woocommerce', 'hide_cart_notes' );
function hide_cart_notes() {
if ( is_archive() ) {
return;
}
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
add_action( 'woocommerce', 'hide_cart_notes' );
when woocommerce hook starts? where it's docs? does it run at all?
these question should be answered before.
i know that WordPress parses query at parse_query hook, so i would try this
add_action('parse_query', function() {
if (!is_archive()) {
add_filter( 'wc_add_to_cart_message_html', '__return_false' );
}
});
because is_shop(), is_archive(), is_* need query to be parsed first.

How to remove wordpress date archive pages?

I have developed my own wordpress theme, and learning all kinds of programming stuff, but my priority is the content, not the programming knownledge. I need to know how to remove archive date listing from wordpress?
Question 1: The google search results displayed like this: virmodrosti.com/2017/05/
I don't want any kind of date archive option, how do you disable that?
I also don't use any kind of plugin, and always like to do it on my own.
Question 2: I don't know why older entries doesn't work anymore
virmodrosti.com/zdravje/ this page works fine
virmodrosti.com/zdravje/page/2/ it redirects to 404 error page
I only choose option in wordpress to hide that annoying /category/ with dash . inside editor at permanlinks, Category base. Maybe somehow these stuff is kinda fighting with each other and doesn't work properly.
Thank you.
This is code from Digital Nomad theme I maintain:
function digitalnomad_remove_date_archives() {
//if we are on date archive page
if ( is_date() ) {
// theme sets alternatine archive page with table like list of all posts
$archive_page = get_option( 'digitalnomad_archive_page' );
if ( $archive_page ) {
// redirs to alternatine archive page if configured (good for SEO)
wp_redirect( esc_url( get_page_link( $archive_page ) ) );
die();
} else {
// otherwise error 404 is displayed
global $wp_query;
$wp_query->set_404();
}
}
}
add_action( 'template_redirect', 'digitalnomad_remove_date_archives' );
Use the smart Archive Page Remover wordpress plugin
or visit your theme's functions.php file
then insert this code
/* Register template redirect action callback */
add_action('template_redirect','makes_remove_wp_archives');
/* Remove archive*/
function makes_remove_wp_archives(){
// if we are on category or tag or date or author archive
if(is_category()|| is_tag()||is_author()){
global $wp_query;
$wp_query->set_404();
}
}

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;
}

Removing pagination from Woocommerce product variations

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 ) )

WooCommerce Url rewrites

I've got the same problem described in this post:
[WordPress URL rewrite for WooCommerce attributes, except that I need to filter by attribute not only inside a category.
Unfortunately, I cannot post a comment before reaching a higher reputation, so I'm creating a new question.
I defined a manufacturer attribute and if I want to browse all products from a certain manufacturer, I can use a url like www.example.com/shop/?filter_manufacturer=230, where 230 is the attribute ID.
I tried adding a endpoint, like suggested in the post linked above above, but I cannot get the rewrites working; for example, if I try to open www.example.com/shop/manufacturer/manufacturer_name I get a 404 error.
It's not clear to me if I should change anything in the permalink settings in Wordpress and, if yes, how.
I've always flushed the rewrite rules after every edit, BTW.
The missing link between your question regarding WooCommerce attributes and the linked answer is that product attributes are merely taxonomies with a 'pa_' appended to their name.
In your case the taxonomy is called "pa_manufacturer". WooCommerce sets these up by default to have no query var attached.
So in lieu of filtering query_vars we are going to target when WooCommerce registers that particular taxonomy. I've also modified to remove anonymous functions.
In my example I am using "color", so adjust to "manufacturer". I was able to then go to a URL of http://example.com/shop/color/black and see all the black products. Note that this doesn't get you a term archive where /shop/color will list all the colors. That is a different question and a lot more work.
I didn't test the activation part, so if you get 404s after activating you can just delete the whole activation function and simply go to Settings>Permalinks and save the permalinks again.
/**
* Plugin Name: Add an WooCommerce attribute endpoint to the URLs
* Plugin URI: http://stackoverflow.com/q/28460538/383847
* Credit to: http://stackoverflow.com/a/24331768/1287812
*/
function so_28460538_add_rewrite_endpoint(){
add_rewrite_endpoint( 'color', EP_ALL );
}
add_action( 'init', 'so_28460538_add_rewrite_endpoint' );
function so_28460538_attribute_args( $args ){
$args['query_var'] = 'color';
return $args;
}
add_filter( 'woocommerce_taxonomy_args_pa_color', 'so_28460538_attribute_args' );
/**
* Refresh permalinks on plugin activation
* Source: http://wordpress.stackexchange.com/a/108517/12615
*/
function WCM_Setup_Demo_on_activation(){
if ( ! current_user_can( 'activate_plugins' ) )
return;
$plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
check_admin_referer( "activate-plugin_{$plugin}" );
add_rewrite_endpoint( 'color', EP_ALL ); #source: http://wordpress.stackexchange.com/a/118694/12615
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'WCM_Setup_Demo_on_activation' );
EDIT
Adding some screenshots of my settings in case it will help determine why you are getting 404s:
Here are my permalinks settings:
and here is the WooCommerce setting for determining the product archive page:
And finally, here is the result of visting:
http://local.wordpress.dev/shop/color/black/
Where shop is the pretty permalink for the product archive page set above. All items have a 'black' color attribute.
I had a similar problem and was able to solve it like this:
function add_model_taxonomy_args($args) {
$args['query_var'] = 'filter_model';
return $args;
}
add_filter('woocommerce_taxonomy_args_pa_model', 'add_model_taxonomy_args' );
function custom_rewrite_rules() {
add_rewrite_tag('%filter_model%', '([a-zA-Z0-9-]+)');
add_rewrite_rule('^c/phone-cases/(.+?)/?$', 'index.php?product_cat=phone-cases&filter_model=$matches[1]', 'top');
}
add_action('init', 'custom_rewrite_rules', 10, 2);
Sample Url: c/phone-cases/iphone-8-plus/
Resulting Rewrite: index.php?product_cat=phone-cases&filter_model=iphone-8-plus

Resources