Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    And if I apply the var_dump that was recommended to me for the query loop in the single.

    var_dump($autor_relationship);

    This appears on the single:

    Fernández Vilas, Ana; Saquicela Galarza, Víctor H.; Zanovello, Paolaarray(3) { [0]=> object(WP_Post)#1944 (24) { [“ID”]=> int(12) [“post_author”]=> string(1) “1” [“post_date”]=> string(19) “2024-05-27 19:15:48” [“post_date_gmt”]=> string(19) “2024-05-27 19:15:48” [“post_content”]=> string(0) “” [“post_title”]=> string(21) “Fernández Vilas, Ana” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(6) “closed” [“post_password”]=> string(0) “” [“post_name”]=> string(19) “fernandez-vilas-ana” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2024-05-27 19:15:48” [“post_modified_gmt”]=> string(19) “2024-05-27 19:15:48” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(49) “https://grupogsii.local/autor/fernandez-vilas-ana/” [“menu_order”]=> int(0) [“post_type”]=> string(5) “autor” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } [1]=> object(WP_Post)#1941 (24) { [“ID”]=> int(95) [“post_author”]=> string(1) “1” [“post_date”]=> string(19) “2024-05-27 19:17:11” [“post_date_gmt”]=> string(19) “2024-05-27 19:17:11” [“post_content”]=> string(0) “” [“post_title”]=> string(29) “Saquicela Galarza, Víctor H.” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(6) “closed” [“post_password”]=> string(0) “” [“post_name”]=> string(26) “saquicela-galarza-victor-h” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2024-05-27 19:17:11” [“post_modified_gmt”]=> string(19) “2024-05-27 19:17:11” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(56) “https://grupogsii.local/autor/saquicela-galarza-victor-h/” [“menu_order”]=> int(0) [“post_type”]=> string(5) “autor” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } [2]=> object(WP_Post)#1943 (24) { [“ID”]=> int(148) [“post_author”]=> string(1) “1” [“post_date”]=> string(19) “2024-05-27 19:18:04” [“post_date_gmt”]=> string(19) “2024-05-27 19:18:04” [“post_content”]=> string(0) “” [“post_title”]=> string(16) “Zanovello, Paola” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(6) “closed” [“post_password”]=> string(0) “” [“post_name”]=> string(15) “zanovello-paola” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2024-05-27 19:18:04” [“post_modified_gmt”]=> string(19) “2024-05-27 19:18:04” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(45) “https://grupogsii.local/autor/zanovello-paola/” [“menu_order”]=> int(0) [“post_type”]=> string(5) “autor” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } }

    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    The relationship custom field works outside of the query loop.

    With the help of this tutorial and chatgpt I applied a code to the CPT Publications single (CPT in which it has the relationship field within the group of fields), the values ??of that field are shown (the names and surnames of the authors).

    And what I would like to achieve is that those values ??were displayed using the QueryLoop of GenerateBlocks.

                   <?php $autor_relationship = get_field('autor_relationship');

    if ($autor_relationship) {
    $autor_titles = array();
    foreach ($autor_relationship as $autor_relationships) {
    $autor_titles[] = $autor_relationships->post_title;
    }
    echo implode('; ', $autor_titles);
    }

    ?>
    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    Hi, this is what happened:

    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    Set up:

    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    I did it by creating a new page where the custom post type to which the relationship custom field belongs is and it didn’t work either.

    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    Thanks for your answer. But I changed linked_consultants to autor_relationship, and nothing happened. The content of the custom field is not displayed.

    That is the code I added in the functions.php file of the child theme:

    add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {

    if (

    ! empty( $attributes['className'] ) &&

    strpos( $attributes['className'], 'related-profiles' ) !== false &&

    ! is_admin()

    ) {

    // get the relate post ID

    $current_post = get_the_ID() ;

    $relationship = get_field( "autor_relationship", $current_post );

    // Merge the current $query_args with the new args

    return array_merge( $query_args, array(

    'post__in' => $relationship,

    ) );

    }

    return $query_args;

    }, 10, 2 );
    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    Sorry. I thought it might be a good idea to use a .gif file but it wasn’t. I hope it worked now.

    Thread Starter oscargonzalezgrande

    (@oscargonzalezgrande)

    It didn’t work. I share a .gif of what happened. Did I make a mistake in some step? If not, is there another way?

Viewing 8 replies - 1 through 8 (of 8 total)