wp query – Upsell product category – Exclude categories

Greatings,

I've achieved what I had to do: replace the Upsell products by category instead of taking the time to add upward sales. I just passed the auto category. But I reached the end of the road. I need to exclude categories to show upstream sales now. But I do not know how to do that.

I will try to clarify everything.

that's the code I'm using in theme functions.php

add_filter (& # 39; woocommerce_product_get_upsell_ids & # 39 ;, & quot; custom_upsell_ids & # 39 ;, 20,2);

function custom_upsell_ids ($ upsell_ids, $ product) {
// HERE define your product categories slug in the table
$ product_categories = array (& # 39; priedai-prie-geliu & # 39;); // <===== <===== <===== <===== <=====

// return the custom query
return wc_get_products (array (
& # 39; status & # 39; => & Nbsp; publish, published products
& # 39; limit & # 39; => 20, // 4 products
& # 39; category & # 39; => $ product_categories, // product categories
& # 39; orderby & # 39; => Rand, // Random order
& # 39; Exclude & # 39; => array ($ product-> get_id ()), // Exclude the current product
& # 39; return & # 39; => & # 39; ids, // Query only returns identifiers

));

}

This code allows me to shop in a specific category. But I have categories where I do not want to show upstream sales – how can I achieve that ???

[GET] – WP Squeeze Lead Theme | NewProxyLists


  1. Heaventrix

    Heaventrix
    Administrator
    Staff member

    • Administrator

    • Global Moderator

    • Moderator

    • Staff

    • VIP

    • Member

    joined:
    March 29, 2014
    posts:
    4,667
    I like receipts:
    2,959
    Trophy points:
    113

    GET-WP Lead Squeeze Theme
    [img=https://i.imgur.com/o6HflOY.png]

    Hidden content:

    You must answer before you can see the hidden data contained here.

  2. Thank you, just what I need

php – Fresh Install WP Error – "The site is having technical difficulties"

Usually, this type of error is associated with a plugin, but not in my case since it is a new installation of the latest version of WP. I receive this error after downloading all the files and ready to be installed.

I am running php 7.2

You do not really know what is causing this error or what needs to be done to solve it.

[GET][NULLED] – WP Cost Calculator and Estimated Payment Costs v9.677

[​IMG]
[​IMG]

[GET][NULLED] – WP Cost Calculator and Estimated Payment Costs v9.677

[GET][NULLED] – WP Cost Calculator and Estimated Payment Costs v9.677

[​IMG]
[​IMG]

[GET][NULLED] – WP Cost Calculator and Estimated Payment Costs v9.677

permalinks – How to create a standard WP page that has the same url as an archive

I've tried Google, but to no avail. I am a beginner in programming but I can say that I am a follower of the WP configuration – nice please, support me please. 🙂

I have a CUSTOM_TAXONOMY that when viewed, the URL of the archive is example.com/custom_taxonomy/actual_taxonomy/.

Since I wanted my posts to have the slug of this new custom taxonomy in all my publish URLs, I went to Settings >> Permalinks in the WP dashboard and set it to "Custom Structure" for example .com / custom_taxonomy%% /%% postname /. I can actually reach my goal of having standard posts with this url schema.

However, when I was about to create a wp page with the URL: example.com/actual_taxonomy to correctly display the archives of my custom taxonomy with some added drawings, it looks like example.com/custom_taxonomy is transformed into a self-archive. with the same provision as in the second paragraph above.

I really wanted to create my own page and set the URL as example.com/actual_taxonomy. However, it already exists because I set it in Settings >> Permalinks. Is there a way to avoid this problem? Thank you guys!

Query Post Preview Updates from the WP API?

Is there a way to view previews of updates to publications already published via the WP API? For example, I update an article that has already been published, I click the Preview button, and I need a URL similar to

http://example.com/my-post/?preview_id=219&preview_nonce=ff84df100b&preview=true&_thumbnail_id=245

Is there a way to access this content via the API?

I am working on a WP project without head and I need a way to display the preview in our custom frontend. I can view Draft status publications, as well as published publications, by clicking on the API. It's the latter case of publishing publications that has additional updates that I can not understand.

Any help is welcome, thank you!

wp query – How to avoid bypassing rules in the search bar?

I build my site locally.

Since I want users to be able to write only specific terms in the search bar, I've placed a jQuery script in the wp-content themes sitename js folder.
The script works well, but I noticed that the script can be ignored in a simple way.

For example, suppose the search bar only accepts 3-character strings. Therefore, if I write a B c d and press enter i get an error but if i write ABC and press Enter, then it works and the Search results the page will have the URL

http: // localhost / sitename /? s = abc

But just change the URL to be

http: // localhost / site_name /? s = abcd

and press Enter to ignore the script in the search bar.

How to avoid this?

I have 2 ideas, use the function get_search_query, or delete the keyword from the URL so that, regardless of the keyword, the URL is, for example

http: // localhost / sitename / search

But I do not know how to use the function or how to remove the keyword from the URL (if it is possible).