Support

Account

Forum Replies Created

  • OK, for those who wants to achieve this, i found a solution which is so far working without a problem :

    You’ll need to use ACF post 2 Post (https://wordpress.org/plugins/post-2-post-for-acf/)

    ACFP2P have a hook that is called after each related post is updated, all you need to do is to use the WPML hook “wpml_admin_make_post_duplicates” on each posts, thus updating your duplicated post data:

    add_action(‘acf/post2post/relationship_updated’, ‘my_post_updated_action’);
    function my_post_updated_action($post_id) {
    // $post_id == the post ID that was updated
    // do something after the related post is updated

    do_action( ‘wpml_admin_make_post_duplicates’, $post_id );
    }

  • PLEASE IGNORE MY QUESTIONS ABOVE…

    After 5 hours of banging my head…i found that i had some custom fields that were not translated and also not set to copy.

    Gotta love coding / wordpress sometimes.

    BTW John i still owe you a beer, please get me a way (Paypal, etc) to send you something for the previous help you gave me. Thanks!

  • OK, i guess that $arts = get_field(‘art_artist’); is actually looking at the artist page ID of the original language…

    If i create a custom Query, i can get the Artworks to be listed in French and English :

    I get the actual artist page ID :

    
    if (ICL_LANGUAGE_CODE == 'en'):
        $id_art = get_the_ID();
    
    elseif (ICL_LANGUAGE_CODE == 'fr'):
        $id_art = get_the_ID();
    endif;
    

    Then :

    $args = array(
    				'post_type' => 'artworks',
    				'posts_per_page' => -1,
    				'meta_query' => array(
    					array(
    						'key' => 'art_artist', 
    						'value' =>  $id_art,
    						'compare' => 'LIKE'
    						)
    					)
    				);	
    

    The problem now is that the post listed do not respect the post order that was assigned in the admin…like I mentioned in my reply of June 12, 2019 at 2:38 am.

    Would you have a better solution?

    Thanks in advance!

  • Hi John!

    We are running into another problem…

    We are using WPML. Everything works fine on the default language (English). But when i try to show the artist related works on the secondary language (French) nothing is shown..

    The var_dump of : $arts = get_field(‘art_artist’); where “art_artist” is my relationship field return a value in the default language, but returns NULL in the secondary language.

    All the Artworks are translated (duplicated).

    Hope you can help me once again!

    Thanks!

  • OMG thank you! The solution was so simple…it works great now, i can reorder both the series and the artworks.

    Do you have a Paypal address? I’m buying you a beer!

  • John, you are right. Since im getting the value of the SERIES post type relationship field, they are indeed classified as in the admin : $series = get_field(‘serie_artist’);

    But, for the ARTWORKS, that are listed under each SERIES, i guess it’s not respecting the order, because i’m doing a get_post :

    $oeuvres = get_posts(array(
    										'post_type' => 'artworks',
    										'post_status' => 'publish',
    										'meta_query' => array(
    											array(
    												'key' => 'art_serie',
    												'value' => $serie->ID,
    												'compare' => 'LIKE'
    											)
    										)
    									));

    Do you see a solution to get the Artworks respect the order of the relationship field? Or is it not feasible?

    I hope i’m clear enough…

  • Here’s the code i’m using.

    
    <?php 
    
    						$series = get_field('serie_artist');
    
    						?>
    						<?php if( $series ): ?>
    							<?php foreach( $series as $serie ): ?>
    							
    								<h2><?php echo get_the_title( $serie->ID ); ?></h2>
    								
    								<?php
    									$oeuvres = get_posts(array(
    										'post_type' => 'artworks',
    										'post_status' => 'publish',
    										'meta_query' => array(
    											array(
    												'key' => 'art_serie',
    												'value' => $serie->ID,
    												'compare' => 'LIKE'
    											)
    										)
    									));
    								?>
    									<?php foreach( $oeuvres as $oeuvre ): ?>
    									
    									        <h3><?php echo get_the_title( $oeuvre->ID );  ?></h3>
    									<?php endforeach;?>
    							<?php endforeach; ?>
    							
    						
    													<?php else :
    														echo "No Works!"; ?>
    													<?php endif; ?>
    

    It’s basically this part i’m trying to get in the right order :

    	<?php foreach( $oeuvres as $oeuvre ): ?>
    									
    									        <h3><?php echo get_the_title( $oeuvre->ID );  ?></h3>
    									<?php endforeach;?>
  • Hi John,

    I manage to get all things working, i stuck with the 3 CPT approach. Thanks again for your tips.

    I have one more question :

    In the WordPress admin, in the Relationship Field of an item, you can drag and drop post on in certain order…

    How can i display my post exactly in the same order as they are in the admin? I tried all the ‘orderby’ => ” in my query, but none seems to work…

    Thanks!

  • OK, i’ll look into that. Might have some questions later.

    Thanks and keep you posted!

  • Hi John!

    Thank you very much for your detailed suggestions. I’m thinking the same as you, as to create a Series CPT would be the more elegant and flexible solution.

    Tricky part with this project, is that we have a searchable catalog (probably going to use Facet WP for that), so exactly like a woocommerce site (series wont matter there), BUT on the artist page itself, client wants the works to be displayed in a slideshow AND divided by series, instead of linking to the actual product page.

    Anyways, i’ll fiddle with the Series CPT today and see what i’m coming up with.

    Thanks again for taking the time to answer me.

Viewing 11 posts - 1 through 11 (of 11 total)