So, is this code only supposed to work AFTER the migration? Because I just changed it on the current site, and now there's an error.
hidden link
Hello,
Minesh is on holiday, will be back on Monday, he will get in touch with you when he is back.
Looking forward to his response. I just updated my files according to his (and this website's) instructions, and now everything is broken.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
I checked on the staging site:
You are saying on live site with the following location post - it does not display any content under the section "Classes offered at this location:":
=> hidden link
Now, when I checked on the staging site I see the same - I do not see any post under section "Classes offered at this location:":
=> hidden link
And when I edit the same post - I do not see any related posts available.
=> hidden link
There are no related posts available for the post "burlington-technical-center" which is why it is not displaying.
I checked other location posts where it displays the posts under section "Classes offered at this location:":
=> hidden link
=> hidden link
When I ran the migration on the live site, it did NOT produce the same results as when you did it on the staging site. It did NOT come up with ONE relationship that was Classes Locations. It came up with TWO relationships that were totally different. That's why it didn't work for me with the code you gave me above.
I don't even know why one of my original files is now messed up on the live site after I restored the database.
I don't understand why the migration would have different results for each of us.
Now I'm going to try to merge the staging site with the original site since that seems to be my only option left.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
It did NOT come up with ONE relationship that was Classes Locations. It came up with TWO relationships that were totally different.
==>
that is true - because the legacy many-to-many relationship was created using two one-to-many relataionship.
As shared before - This is how you can merge two one-to-many relationships to create many-to-many relationship:
=> https://toolset.com/documentation/post-relationships/how-to-merge-existing-post-relationships/
*** Please make a FULL BACKUP of your database and website.***
So, you should merge the two one-to-many relationships you see by following the above doc so it will become many-to-many relationship.
Your instructions ARE NOT WORKING. I have now merged the database from my staging site with the live site. So now it is just what you did with the same class-location relationship. Except for some reason the same classes archive file (archive-classes.php) from the staging site isn't working on the live site. Plus, that file doesn't even have the code you gave me above. When I use the code you gave me, the page doesn't work AT ALL. This is a total nightmare. It's giving me errors I didn't even have before. hidden link
Compared to what's on the staging site using the same database and file.
hidden link
I thought you told me what you did on the staging site was correct? Now I copied that onto the live site, and now you're telling me it wasn't correct.
So, this only even remotely works with the old code:
$childargs = array(
'post_type' => 'class-link',
'numberposts' => -1,
'orderby' => 'title',
'order' => 'ASC',
'meta_query' => array(array('key' => '_wpcf_belongs_class_id', 'value' => get_the_ID()))
);
$child_posts = get_posts($childargs);
foreach ($child_posts as $child_post) {
$location_id = wpcf_pr_post_get_belongs($child_post->ID, 'location');
And somehow the file is broken now in a different way as you can see here:
hidden link
I don't know what the hell is happening.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
I've updated the single-location.php file as per the information I shared here:
=> https://toolset.com/forums/topic/need-help-converting-code-to-new-relationship-method/page/2/#post-1508735
I can see on your live site - it's working as expected:
=> hidden link
I just show you the method of how you can update the file - you need to update other files accordingly with a relationship keeping in mind. If you need more help please feel free to contact me.
So, let's go step by step - can you please confirm you understand what I've added to single-location.php and single location post on frontend displays the information as expected:
=> hidden link
- I see 8 related posts on frontend and the same displayed on the backend with the same location post:
=> hidden link
So, incidentally, all of my code was backwards compatible, and I spent days working on this for nothing. I'm now using the original files I had, and they all work.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Ok - but its better for the future that as you already spent time on this you should now go ahead and convert the code as per the new relationship as you may expect and it might be possible that legacy relationship code may be broken any time.
I let you decide - if you want to convert the code - I'm happy to help you as always.