Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature "Sync associated taxonomy with this relationship" not working #7332

Open
moscatovida opened this issue Aug 6, 2024 · 9 comments
Open
Assignees
Labels
Status: Need User Feedback Waiting on feedback from user who reported issue Type: Bug
Milestone

Comments

@moscatovida
Copy link

Description

The feature "Sync associated taxonomy with this relationship" does not seem to work properly. When editing a post, the term chosen in the relationship field is ignored.

Also: The option field is actually an empty plain text field. There is no explanation on how to use it and which value should be used to enable the sync.

Version

3.2.6

Testing Instructions

  1. Create a taxonomy
  2. Connect this taxonomy to a post
  3. Add a new relationship field to a post based on the new taxonomy
  4. Edit a post and select a term of the taxonomy in the relationship field (NOT in the taxonomy sidebar)
  5. Save the post
  6. Unfortunately, the taxonomy term has not been associated with the post (the sync does not work)

Screenshots / Screencast

No response

Possible Workaround

No response

Site Health Information

No response

Pods Package

No response

@nreljed
Copy link

nreljed commented Aug 13, 2024

I just discovered this post
Let me add an additional resource

As you can see currently Pods Sync associated taxonomy is not working and if it is fixed it,
the snippet code should see the terms attached,
otherwise it is another bug that we should find, I have not managed to find where it comes from

@moscatovida
Copy link
Author

Thanks for your reply … looking forward to the fix :)

@rosa2
Copy link

rosa2 commented Aug 14, 2024

I was getting crazy because my pages for custom taxonomies made with Pods always returned 0. I have just realized that they were not been sincronized.
I go to test this solution while this gets solved https://wordpress.org/support/topic/how-to-use-sync-associated-taxonomy-with-this-relationship/

@rosa2
Copy link

rosa2 commented Aug 14, 2024

At the end, I used your snippet in https://docs.pods.io/code-snippets/update-taxonomy-value-stored-relationship-field/ and its working in the database. I hope you can give time to solve this. Thanks

Also in my custom taxonomy I don't get the option to "Show in taxonomy archives" https://docs.pods.io/files/2021/08/Screen-Shot-2021-08-22-at-10.48.38-AM-1024x623.png
I get at the bottom: Add new connection with the link to Create a new Custom Post Type

@rosa2
Copy link

rosa2 commented Aug 15, 2024

If I go to the taxonomy in admin wp-admin/edit-tags.php?taxonomy=taxonomyname the count for each term doesn't work and shows 0.
I have tested and the table that gets updated with your site snippet is postmeta and not in term_taxonomy, cell count.

@sc0ttkclark
Copy link
Member

@rosa2 Custom taxonomies already show any associated post type on their archive pages so that option in Pods only shows if you choose to associate a custom post type with Category or Post Tags taxonomies.

I've got the syncing confirmed working in Pods 3.2.7 with the latest testing. Let's check that on your side after the release goes out today and we can close this if that is resolved for you now.

@sc0ttkclark sc0ttkclark added this to the Next Release milestone Aug 28, 2024
@sc0ttkclark sc0ttkclark self-assigned this Aug 28, 2024
@sc0ttkclark sc0ttkclark added the Status: Need User Feedback Waiting on feedback from user who reported issue label Aug 28, 2024
@nreljed
Copy link

nreljed commented Sep 3, 2024

hello,
I confirm with having tested on 3 clean installations (local wp app)

Capture d'écran 2024-09-03 204417
Capture d'écran 2024-09-03 210753

I have a strange error, i will try to capture it in video for you
as you can probably notice , it is totally unpredictable it can happen randomly

Enregistrement.De.L.ecran.2024-09-03.204755.1.mp4

everything works normally but you have to click on refresh this error screen which is scary and everything works as expected, until you make another choice or you create another entry
i paste you all the log

`
Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\fields\pick.php on line 1974

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\fields\pick.php on line 1975

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\fields\pick.php on line 2003

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\fields\pick.php on line 2003

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6296

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6296

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6299

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6302

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6302

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6305

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6305

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6320

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6322

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6331

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6338

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6364

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6376

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6430

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 6431

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8137

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8137

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8147

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8147

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8159

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8166

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8192

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8219

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8220

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8224

Warning: Trying to access array offset on value of type null in C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php on line 8225

Warning: Cannot modify header information - headers already sent by (output started at C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php:8137) in C:\Users\nrelj\Local Sites\test\app\public\wp-includes\pluggable.php on line 1435

Warning: Cannot modify header information - headers already sent by (output started at C:\Users\nrelj\Local Sites\test\app\public\wp-content\plugins\pods\classes\PodsAPI.php:8137) in C:\Users\nrelj\Local Sites\test\app\public\wp-includes\pluggable.php on line 1438`

I hope that the error can be found and corrected 🙏
thank you for your time and making pods better 💪

@nreljed
Copy link

nreljed commented Sep 26, 2024

Hi,

I think the ultimate fix for this bug will be for version 3.2.9 ,
sorry to remind you again I had the feeling that this detail could be easily forgotten , so I confirm it again
in fact it is not a detail, it is even the ultimate interest of Sync associated taxonomy

normally to check if the bug has been fixed correctly , do the test , we should see the same result that ACF does with the same code snippet

test-seo

to reproduce :

  • Create a CPT "property" or other and similar taxonomies or other

  • Install Rankmath Free

  • Apply the code snippet (change values acrroding to your test conditions)

/**
 * Function to update Rank Math Focus Keywords for properties using specified taxonomies
 */
function update_property_focus_keywords() {
    $properties = get_posts(array(
        'post_type'      => 'property', // Replace 'property' with your actual CPT name
        'posts_per_page' => -1,
        'post_status'    => 'publish'
    ));

    $taxonomies = array('property-status', 'property-type', 'property-city');

    foreach ($properties as $property) {
        $keywords = array();

        // Get terms for each taxonomy
        foreach ($taxonomies as $taxonomy) {
            $terms = get_the_terms($property->ID, $taxonomy);
            if ($terms && !is_wp_error($terms)) {
                foreach ($terms as $term) {
                    $keywords[] = strtolower($term->name);
                }
            }
        }

        // Update Focus Keyword even if it exists
        $focus_keyword = implode(', ', array_unique($keywords));
        update_post_meta($property->ID, 'rank_math_focus_keyword', $focus_keyword);
    }
}

// Hook the function to run when WordPress initializes
add_action('init', 'update_property_focus_keywords');

  • Create a post and save

  • You should see your focus keywords

I hope i was able to provide enough data to diagnose the source of the problem

@rosa2
Copy link

rosa2 commented Oct 14, 2024

Thanks a lot for your so well related experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Need User Feedback Waiting on feedback from user who reported issue Type: Bug
Projects
None yet
Development

No branches or pull requests

4 participants