Forum Replies Created
-
AuthorPosts
-
eazy
ParticipantHello, can you update the link?
I got 404 for this: https://github.com/wpmetabox/meta-box/tree/ajax-postalso when you will merge all this to master and realese the new version including all this improvements?
eazy
ParticipantThanks for the support, actually this works for now. Optimal choise would be ajax for both selects, inside "to" and "from" posts. But for now i'm ok with this solution.
eazy
ParticipantHi, any help on how i get this done?
eazy
ParticipantHello, so i tried but it's not working, here the code i put into functions.php:
add_action('mb_relationships_init', function () { $currentPostId = 86323; //how do i get this? global $wpdb; $filteredIds = []; $results = $wpdb->get_results($wpdb->prepare('SELECT * FROM wp_mb_relationships WHERE wp_mb_relationships.to = %s', $currentPostId)); foreach($results as $result){ $filteredIds[] = $result->from; } MB_Relationships_API::register(array( 'id' => 'episodes_to_series', 'from' => array( 'type' => 'post', 'post_type' => 'episode', 'admin_column' => true, 'meta_box' => [ 'context' => 'advanced', 'title' => 'Serie' ] ), 'to' => array( 'type' => 'post', 'post_type' => 'serie', 'meta_box' => [ 'context' => 'advanced', 'title' => 'Episodes' ], 'query_args' => [ 'post__in' => $filteredIds], //not working ), )); });how do i get $currentPostId ? i tried with $post but without success
why $filteredIds is not working?I also tried with hard-coded array instead of filteredIds, but nothing
Also, the bug i mentioned on #14776? Some fix is coming soon?
eazy
ParticipantHi,
the first solution will cause a big problem, when you save the post, all relations will be lost when you save again the post.Then i found a bug, if you try to order the connected posts, when you reload a page, it will go back to its original order, in database all seems fine, but on frontend no.
To replicate this issue, create some related posts
Test1
Test2
Test3-> save -> reload page -> move Test3 to first position -> save -> reload page
you will see the order is resettedeazy
ParticipantHi,
thanks for fast reply.Sadly i can't use the ID's because all 100k posts are related to each other and i can't limit the query.
I need to set this limit to query that populates the select2, instead of showing all options, i need to show/render only the selected option, so the page will load fast because html output will be a lot less.
eazy
ParticipantThanks a lot, this helps the UI, but options rendering in html can be disabled?
If we have, 100k posts, and have relations post to post, every select will have 100k options and page load speed will be slow, some browsers will crash, i want to disable other options rendering, and render only the "selected" option. So user can order only the related items.
eazy
ParticipantAny help is appreciated
eazy
ParticipantHello, is there any news about this feature?
Can't you make some wrapper function (where you can pass and array of parameters) for ajax_callback that uses search feature of:
wp-admin/edit.php?s=test&post_status=all&post_type=post&action=-1&m=0&cat=0&paged=1&action2=-1the get parameters of this search is the array i said before, the search will return an array of [post_id , post_title], if found any, and will be used as select option.
You can also trigger the search when a minimum of words is typed, or just add some button.test_initial_callback can be just the load of the field, if any value is found on database, for sure this is way better than loading an select with all possible options and populating the html.
I think you can do this and merge the feature on live (i think even something basic is appreciated by anyone)
I'd like to help you, but xdebug on wordpress/windows is not working, also i work mainly on Magento, and neved did something complicated on wordpress.
Personally I'd like to see this feature on post_relation plugin.
-
AuthorPosts