• I am trying to add all product categories to menu at once, but the window with categories is too small and resizing it with right click and ispect element etc. is useless because even if the window is taller, there is still the pagination at the top so the products are not all at the same page, so I can not select them all at once and add them into menu.

    So, Is there any way to force the window with product categories show all of the categories at once / at one page?

    This is how it looks right now

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The product category meta box uses WP_Term_Query to get the product category terms to list. The ‘number’ and ‘offset’ arguments are used to manage pagination. You can use the ‘pre_get_terms’ action to alter the arguments used. Setting ‘number’ and ‘offset’ to 0 will return all terms.

    I’m unsure how the meta box will react since it was expecting a limited set of terms. It will likely list the pagination links even though all terms are on the current page. You could hide the pagination links with CSS since they no longer are useful.

    Another issue is altering the arguments as described would alter ALL WP_Term_Query::get_terms() calls for any taxonomy. This might be OK, or cause problems elsewhere on the site. If there are other problems, the altering of arguments will need to be done conditionally. There may be some unique characteristics in the query that serves to identify a product category meta box call from all others — including the product_category taxonomy to begin with, and the number argument value may be another.

    If such a “fingerprint” is not feasible, you may be able to selectively add your action hook from another action or filter that fires before the meta box is populated and only fires for the edit product screen. Or perhaps a combination of the two. The latter to reduce the number of possible calls, then the other to distinguish the one call from a limited set of calls.

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress add all the product categories to menu at once’ is closed to new replies.