In WooCommerce wc_get_orders() documentation there is an argument called parent which as following description:
Accepts an integer: post ID of the order parent.
What is the order parent and what is the use case of this argument?
parent argument is the same as other post types. for example, we generally see in the page hierarchy.
I might be wrong at some point but, with orders, it's used with shop_order_refund post type, whenever you have a partial refund a new post will generate with post type shop_order_refund, and the post parent id will be assigned on this post data.
Related
Made a script for updating a wp post custom fields. All works fine for the fields with type text or number but a I have issues updating the field of type PostObject that contains a select list. Can not find any info on the format of the argument that must be passed to the update_post_meta() in order to update the selected value in the WP database of type PostObject.
For now the post id is static just for testing. And do not take into consideration the field name of the $_GET[] const. It is related to a other custom field. It is just given to see structure of the script.
My script test version I use tot change a specific custom field.
The select where I ge the value from. It returns a string.
Options of the field I want to change from user input.
Plugin name:
Found the solution with the trial and error method :-))).
So, in case you are modifying a custom field of type PostObject, you have to pass as the 'value' argument the ID of the post you want to be the new value of the custom field:
update_post_meta( 15896, 'specialita', '208' );
Thus, in this case the old post ID was for example 325 and and we replace it with a new post with the ID 208.
In wordpress I have a custom post type (generated through the ACF plugin) of job offers which include several text fields (meta_key values) which the plugin "post grid pro" will display no problem. However, I have one field which is the agency that posted the job offer.
This is a relationship field and whenever I add this meta_key to the list of fields to display within each block of my grid it displays simply "Array".
I have tried creating my own shortcode to display this field but alas, this does not work.
There is a page in the site, written by one of the original developers, which lists the job offers. They have managed to display the title of the job agency in php with:
<?= get_field("agence")[0]->post_title ?>
I would like to be able to either write my own shortcode to display the agency title or somehow dynamically create a new meta_key for each job offer which contains automatically the name of the agency derived from the relationship field "agence".
Any help would be vastly appreciated.
Instead of using the relationalship ACF field type, use the one called "Post Object". As long as you don't enable "Select multiple values?" option this will only return a single post object.
This post lists the difference between the two field types. Basically, they both return post objects, but they have slightly different options, and relationship fields always returns the result in an array. You could technically use the relationship field and set the minimum and maximum number of posts to 1, but the post object field is the most appropriate one to use when you only want a single post.
Can we call one taxonomy term from another as a parent and child relation for example I need to click on product category and that show me product series page and when I click on product each series that will lead me to actual product detail means node, so I have two taxonomies category and series I am about to click on category to carry me to series page and then to click on series page to carry me to product detail page on the concern series”
no codebase problem
i am expecting that these two taxonomies may be used as i have mentioned in the question summary but, i can't do it so i hope some help in resolving this issue
Let's look at this answer, I hope it will help you.
Taxonomy terms from the same vocabulary filtered and referenced on multiple content types
To do this you’ll need to have the Entity Reference module installed. So get that out of the way quickly with drush dl entity reference -y and drush en entityreference -y if you haven't already.
First up, we need the taxonomy set up.
Let's demonstrate with the help of an image.
You’ll notice that these terms could be more or less grouped into two categories: Transport and Sleeping. One term (couchette) kinda fits both criteria and is there to exemplify the reason for not using 2 different vocabularies to handle the issue. Now we need to technically make the distinction between these terms as well and since they are entities, we can use a field for that.
So we can now go ahead and add a new field to this vocabulary of the type List (text) with whatever widget you’d like (and let’s call the field Type). You should make the allowed number of values unlimited and put the following in the allowed values list:
Edit each term and select the appropriate type. As expected, for the term couchette, you should select both options.
Now that we have our taxonomy squared away, it’s time to create a View that will handle the filtering of these terms. Because if we now add the Tags taxonomy term reference field to our content types in the normal fashion (as it is already present in the Article content type) we’ll be able to select all the terms in the vocabulary for all the content types. And that's not what we want now.
So create a drupal 7/8 View that shows taxonomy terms of the Tags vocabulary - let’s call it Tags Filter. Add 2 displays of the type Entity Reference and a filter of the field we added to our terms earlier. So for instance the first display can show the terms which have Sleeping selected and the other one can show terms which have Transport. Save the View and you can close it.
Now finally we can edit our content types and add to each a new field of the type Entity Reference with a select list widget. For the target type select Taxonomy term and under Entity Selection choose the following: for Mode, go with Views: filter by entity reference view and then select the View in question - one of the two displays which we created earlier. In the picture below, I named one of the displays
Drupal 8
I have a content type with a field that holds a Taxonomy Term Reference. I want a View that shows other nodes of the same content type that do not have that field with the same Taxonomy Term ID as the currently viewed node.
Example:
URL: /story/storyA
Currently viewing a node of Content Type Story that has a Taxonomy Term Reference to value B. I need the view to show other stories that do not have that same Taxonomy Term Reference to value B.
I thought I could achieve that by
Set up a relationship to the field that holds the Taxonomy Term
Add a Filter Criteria of Term ID associated to above relationship and with operator is not equal to. PROBLEM: how do I get the token for Value?
I also tried to go about adding a Contextual Filter associated to the created relationship and selecting Exlude but no dice.
I finally figured it out, I was missing the adequate additional Contextual Filter:
Term ID , Provide default value with Taxonomy term ID from URL and the options Load default filter from node page and limit terms by vocab checked. And the last bit, in More, I have Exclude checked. This contextual filter is associated to the created relationship mentioned in the question.
I have a Content-Type with taxonomy-terms. It's a select-list, so it can have only one taxonomy - at least of that vocabulary. Now I need to build a view that lists all nodes with the same taxonomy.
Thought that this wouldn't be too hard since it sounds pretty basic. Yet I can't get it working. Any ideas? I'm trying to avoid writing a module for this.
While this was technically possible with Views 2 as described in some of the other answers, Views 3 has this integration built in.
You can create an argument for the taxonomy term id and then choose "Provide default argument". This will then give you an option for "Taxonomy Term ID from URL" and "Load default argument from node page..."
This will allow you to take the taxonomy of a page and pass that as an argument to your view block.
Note: Views 3 is currently in Alpha 3 but in my experience is at a relatively stable state and I am using it on production sites. If it has features like the one above that you find useful please use it, test it and submit bugs/patches if you encounter any issues!
This answer works in Views version 2 or higher. First you need to install Views attach ( http://drupal.org/project/views_attach ). Please read about Views attach before proceeding further. Views attach is best explained by this video http://mustardseedmedia.com/podcast/episode37
Now we get to Views attach. Please enable the views attach module before proceeding. Essentially Views attach attaches a view at the end of the node. In our case our view will be a listing of other articles with the same term.
We will essentially need to "pass" the taxonomy term of the node to the view. Let the name of your Vocabulary be called MyVocab.
Steps to make the view.
Lets call the view display_other_articles_with_same_taxonomy.
Add a display of type Node Content (available after enabling Views attach). This is a display just like block and page displays but with special ability of attaching itself to the node.
Make the following settings in the Node Content Display
Node content settings
Node types: [select the content types you are interested in seeing the list of nodes with same taxonomy term]
Build modes: Teaser, Full node
Arguments: token
Show title: No
You should select Use tokens from the node the view is attached to under Arguments. Let the token be [term-id] This is the "ID of top taxonomy term". This is very important!! Essentially you are going to be passing the taxonomy term of the node from the MyVocab (See http://groups.drupal.org/node/11788#comment-38332). If it has the lowest weight, the taxonomy vocabulary will be the first vocabulary in the taxonomy section of your node edit form. Add an argument Taxonomy: Term Id.
Add the fields you are interested in e.g. Node: Title. Make sure the Node: Title is made into a hyperlink by ticking Link this field to its Node
So what this view is going to do is:
Take the taxonomy term from the MyVocab vocabulary in the Node that is currently being viewed
Pass that as argument to the view display_other_articles_with_same_taxonomy
List all the nodes that have the same taxonomy term as the node being displayed.
Thats it!
If you're using Views 3 (currently at alpha3 at the time of writing) and you want a block (right now the articles have same taxonomy term come at the end of node body) you can do it in the following fashion:
Forget about views attach... its not required
Add a block view. It should contain the same argument, fields and filters as the instructions above for the Node Content display.
You need to modify the settings for the argument Taxononomy: Term Id just slightly: Under Action to take if argument is not present: choose [x] Provide Default Argument. Choose [x] Taxonomy Term ID from URL. Now make sure [] Load default argument from term page is unselected and [x] Load default argument from node page, thats good for related taxonomy blocks. Also [x]Limit terms by vocabulary and choose the Series vocabulary.
Make sure you name the block and put it in the appropriate region.
Note: This answer is subset of the answer I provided at How to just show NodeQueue block on included nodes? In that scenario the requirement was that the related articles are explicitly selected and listed in a particular order. Its a little more complex and uses Nodequeues which we don't need here at all.
Use relationships
Node 1 -> Relationship 1 -> Term // This will be relationships->taxonomy->term
Term -> Relationship 2 -> Node 2 // This will be relationships->node->node
Argument NID to filter NODE 1
Fields or node full view on Relationship 2 (you will see select box on field adding form, to determinate what NODE to use)
Views gives you the options to add filters. Click the plus sign in the filters area of the views admin UI, select Taxonomy from the list, check either Term or ID, and fill in the value that you need to filter by.
EDIT (for explicit instructions):
First, add the necessary fields that you want under the fields section that you want to display from the nodes that you are trying to filter such as node title, etc.
Under Arguments, click the plus sign and select Taxonomy
Check Taxonomy: Term and click Add
Click Update
In your preview area test it out by adding an argument and clicking preview. If it doesn't work, your nodes do not have attached taxonomy, your views module is corrupted, or you didn't follow directions.