Forum Replies Created
-
AuthorPosts
-
JasonKeymasterI’m a bit confused as to to what that would solve? As specified in the other thread, I’m using both post-relate and my own select-relate. Wouldn’t changing that line break post-relate as it is? I need both to work side-by-side.
For a bit I’m going to move on from this. Adding the hidden field to select-relate did enough for me to differentiate the fields, and I’ll include post__not_in (array(0)) in my queries to ignore the has_post_id = 0 values. It’s not awesome, but it works.
JasonKeymasterI have the gist (https://gist.github.com/JasonTheAdams/9142065) to a point where it’s storing the relationship. The only bug is that if I use this simultaneously to the post-relate field it stores the extraneous field where the post_id is correct, but the has_post_id is 0.
JasonKeymasterCorrect. One is an “Author” (single People CPT using select-relate field I made) and the other is “People Involved” (multiple People CPT using post-relate field). If I mark a person as Author and update the post, it will then show that person as the Author AND in “People Involved”, since it doesn’t differentiate.
I know it’s a strange case, but this has been an interesting project.
JasonKeymasterI came up with a workaround.. that I’m not crazy about, but it works.
I added a hidden field that stores the id for the specific field in the wp_postmeta table. I can then check the relation against this meta-value to see which field it belongs to.
JasonKeymasterStill really hoping to hear any thoughts on this. Perhaps it’d be useful to add an additional column to the wp_post_relationships table that stores the field name that inserted the relationship?
In the meantime, I’m at a bit of a loss. I could store the ID as a post meta, but then I lose the bi-directional relationship.
JasonKeymasterI can’t spend any more time on this, presently. But I’m still very open to suggestions.
In case someone else needs this before the post-relate is configurable, my workaround is going to be to use the post__not_in = array(0) argument to sift out the bad references. This does, unfortunately, mean unnecessary rows in the database, but that’s not a big deal.
JasonKeymaster@Steve
That sounds great! ..But I kind of need this now. Can you please offer any insight into my situation? I’m starting to spend too much time on this particular asset for the project I’m working on.
JasonKeymasterHey Marcus! Well.. I’ve dabbled a bit more, and while I think it’s functioning a bit more robustly, I can’t seem to figure out the extraneous post_id=0 bug. I’m really running out of ideas. There’s clearly something going on that I can’t see, as I’m never even appending values to the $scope_select_relate field; only the remove field. I’m wondering if the magic behind that is having an issue.
When you say “default setting”, are you referring to the $default variable?
Thanks! Hoping to give this one to the Piklist team when all is said and done so it can lunch as another ready-made field.
JasonKeymasterI’m close! The record is being added to the database… but it’s adding a row with has_post_id = 0. I assume it’s adding one per post, but I’m only experimenting with two.
JasonKeymasterNevermind about the line. I figured it out. But I’m still having difficulties getting this to work. 🙁
JasonKeymasterAlso, please help me understand this line:
$(‘:input.<?php echo $scope . ‘_post_id’; ?>[value=”‘ + current_value + ‘”]’).prop(‘checked’, $(this).is(‘:checked’));I’m having trouble understanding what this is accomplishing.
JasonKeymasterHey Marcus!
Thanks for pointing me in the right direction!
I’m working on a custom field, and while I’m getting the select to populate with the items, I’m having trouble getting the relationship to save.
What’s confusing me is how the post-relate field works. There’s two hidden fields, $scope_relate and $scope_relate_remove, and I assume the values applied to these fields determines whether an id is added or removed. The only values applied, however, are to $scope_relate_remove; no values are ever added to $scope_relate, although it has a ‘value’ => ‘has’ field. I’m not sure what that does. Does it simply determine the relationship to be ‘has’ or ‘belongs’?
My code can be found here: https://gist.github.com/JasonTheAdams/9142065
JasonKeymasterI’m using WordPress 3.8.1 from Chrome 32.0.1700.107 on Ubuntu 12.04.
Thanks, Kevin!
JasonKeymasterThanks, Steve! Updated doc is perfect.
JasonKeymasterNice. That’s definitely one of those argument parameters I’ve never paid attention to. Makes sense!
Unfortunately, now I’m not getting any posts, but I believe I understand why. The people are being tagged from the other post types, which means the post_id in the db is, for example, projects, and the has_post_id is the person. I assume you’re doing the query in direction of joining the id to wp_posts.id to wp_post_relationships.post_id. This means the relationship is one-sided.
Do you happen to have an argument that joins to the has_post_id column? Otherwise I’ll need to write my own query.
Thanks!
EDIT: Just found post_has, please add this to the docs! I didn’t see it in there and it’s exactly what I was talking about! 🙂
-
AuthorPosts