Giter Site home page Giter Site logo

Comments (4)

Hube2 avatar Hube2 commented on August 20, 2024

This could have something to do with where and when you are adding the field groups in PHP.

In what file is your code?

When is it executed? Are you using a specific hook?

from acf-post2post.

psntr avatar psntr commented on August 20, 2024

The field groups in PHP are in a file called bones.php which is directly called in the beginning of my functions.php

So in the bones.php I have all the functions hook. For the ACF field group I have this:

function my_acf_add_local_field_groups() {
if( function_exists('acf_add_local_field_group') ):
…
endif;
}

After that, in my functions.php I called the file containing my hooks:

require_once( 'library/bones.php' );

After the require_once, I have this function:

function rt_launch() {
require_once( 'library/custom-post-type.php' );

  // launching operation cleanup
  add_action( 'init', 'rt_head_cleanup' );
  // A better title
  add_filter( 'wp_title', 'rw_title', 10, 3 );
  // remove WP version from RSS
  add_filter( 'the_generator', 'rt_rss_version' );
  // remove pesky injected css for recent comments widget
  add_filter( 'wp_head', 'rt_remove_wp_widget_recent_comments_style', 1 );
  // clean up comment styles in the head
  add_action( 'wp_head', 'rt_remove_recent_comments_style', 1 );
  // clean up gallery output in wp
  add_filter( 'gallery_style', 'rt_gallery_style' );
  
  // Init ACF
 add_action('acf/init', 'my_acf_add_local_field_groups');
}
add_action( 'after_setup_theme', 'rt_launch' );

Below that group, there is other functions as such as:
add_image_size
update_option (size of some thumbnails)
$wp_customize->remove_section


Basically it's called after_setup_theme, as the hook is in my rt_launch function. What do you think?

from acf-post2post.

Hube2 avatar Hube2 commented on August 20, 2024

this is how it appears to me

On the Exhibition post type you have a relationship field name "artist_related", but on the Artist page you ave a field named "exhibition_related". If these two fields need to be bidirectional with each other then they are not named the same.

Exhibition and Work share a field named "artist_related", these two fields will be bidirectional. I don't think this is what you had in mind.

This means that selecting an "Artist" when updating a "Exhibition" the artist will not be updated because it does not share a commonly name field on the artist post type.

When I create fields to use with this plugin I try to name them using the post types that will be related.

for example, looking at your field setup you need 4 fields (7 actually counting the fields for each post type):
exhibition_to_work (used on the exhibition and work post types)
exhibition_to_artist (used on the exhibition and artist post types)
work_to_artist (used on the work and artist post types)
work_to_work (uses only on the work post type)

Sorry, I should have seen that in the OP. I didn't look at the fields you set up as carefully as I should have.

from acf-post2post.

psntr avatar psntr commented on August 20, 2024

I took your comments in account and renamed the field accordingly. And now it works both ways!
You were right, I was a bit confused on how to use the field name for the relationship, but it's quite clear now.

Thank you for your help!

from acf-post2post.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.