pods-framework / pods

The Pods Framework is a Content Development Framework for WordPress - It lets you create and extend content types that can be used for any project. Add fields of various types we've built in, or add your own with custom inputs, you have total control.
https://pods.io/
GNU General Public License v2.0
1.07k stars 264 forks source link

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

Open moscatovida opened 3 months ago

moscatovida commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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

rosa2 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 2 months ago

@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.

nreljed commented 2 months ago

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

https://github.com/user-attachments/assets/0238a439-0a20-404d-a769-1112c381544e

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 commented 1 month ago

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 :

/**
 * 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');

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

rosa2 commented 1 month ago

Thanks a lot for your so well related experience.