Gutenberg Block with Relation does not work anymore

Support MB Relationships Gutenberg Block with Relation does not work anymore

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #40387
    MariusMarius
    Participant

    Hi,

    i have a MetBox Gutenberg Block with the following Code:

    <?php
    $connected = new WP_Query( [
        'relationship' => [
            'id'   => 'kontakte-auf-seiten',
            'to' => get_the_ID(), // You can pass object ID or full object
        ],
        'nopaging'     => true,
    ] );
    while ( $connected->have_posts() ) : $connected->the_post(); 
    ?>
    <div class="wrapper">
        <div class="person">
            <figure><?php echo get_the_post_thumbnail( $page->ID, 'kontaktpersonen' ); ?></figure>
            <div class="person-innercontent">
               <!-- <h5><?php $value = rwmb_the_value( 'anrede' );  ?></h5>-->
            <h3><?php the_title(); ?></h3>
            <p>Tel.: <a href="tel:<?php $telefon = rwmb_meta( 'telefon' ); echo $telefon; ?>"><?php $telefon = rwmb_meta( 'telefon' ); echo $telefon; ?></a><br />
            Fax: <?php $fax = rwmb_meta( 'fax' ); echo $fax; ?></p>
            <p class="m-ail kontakt-mal"><a href="mailto:<?php $email = rwmb_meta( 'email' ); echo $email; ?>"><?php $email = rwmb_meta( 'email' ); echo $email; ?></a> </p>
            </div>    
            <a href="mailto:<?php $email = rwmb_meta( 'email' ); echo $email; ?>" class="kontakt-button">Kontaktieren</a>
    
        </div>
    </div>
        <?php
    endwhile;
    wp_reset_postdata();
    ?>
    

    The in a page, where i add the Block, i select the relatiosnhip in the Sidebar, and the Blcok renders the Related Post Type elements. S´This used to work, But now it does nto show the renderigns anymore…

    Do you have an idea, why that could be?

    #40392
    MariusMarius
    Participant

    Sorry for my sloppy typing abovw…

    This used to work – but now it does not show the related items anymore…

    #40396
    PeterPeter
    Moderator

    Hello Marius,

    In the template file or callback function, please use the variable $post_id to get the current post ID where you use the custom block. Please read more on the documentation https://docs.metabox.io/extensions/mb-blocks/#render_callback

    For example:

        'relationship' => [
            'id'   => 'kontakte-auf-seiten',
            'to' => $post_id, // You can pass object ID or full object
        ],

    Then pass the page ID variable to the third parameter of the helper function

    rwmb_meta( 'fax', '', $page->ID )

    Let me know how it goes.

    #40405
    MariusMarius
    Participant

    Hello Peter,

    thanks for your feedback.

    Unfortunatly no success…

    I rewrote it to this:

    <?php
    $post_id = get_the_ID();
    $connected = new WP_Query( [
        'relationship' => [
            'id'   => 'kontakte-auf-seiten',
            'to' => $post_id, 
        ],
        'nopaging'     => true,
    ] );
    while ( $connected->have_posts() ) : $connected->the_post(); 
    ?>
    <div class="wrapper">
        <div class="person">
            <figure><?php echo get_the_post_thumbnail( $page->ID, 'kontaktpersonen' ); ?></figure>
            <div class="innercontent">
               <!-- <h5><?php $value = rwmb_meta( 'anrede', '', $post_id );  ?></h5>-->
            <h3><?php the_title(); ?></h3>
            <p>Tel.: <a href="tel:<?php echo rwmb_meta( 'telefon', '', $post_id ); ?>"><?php echo rwmb_meta( 'telefon', '', $post_id ); ?></a><br />
            Fax: <?php echo rwmb_meta( 'fax', '', $post_id ); ?></p>
            <p class="m-ail kontakt-mal"><a href="mailto:<?php echo rwmb_meta( 'email', '', $post_id ); ?>"><?php echo rwmb_meta( 'email', '', $post_id ); ?></a> </p>
            </div>    
            <a href="mailto:<?php echo rwmb_meta( 'email', '', $post_id ); ?>" class="kontakt-button">Kontaktieren</a>
    
        </div>
    </div>
        <?php
    endwhile;
    wp_reset_postdata();
    ?>
    #40406
    MariusMarius
    Participant

    Additional Question: Is this related to PHP 8? Because i did the switch a few days ago and maybe since then it it not workign anymore…

    #40407
    MariusMarius
    Participant

    And i build it last year, with the MB Blocks Plugin

    #40432
    PeterPeter
    Moderator

    Hello,

    If you view the block in the admin area, please remove this line in your code

    $post_id = get_the_ID();

    If you view the block in the frontend, you can keep it.

    If it still does not work, please share your site credentials (should be a staging site so I can make some tests there) to the contact form https://metabox.io/contact/, and let me know where I can find your code. I will take a closer look.

    #40505
    MariusMarius
    Participant

    Hi Peter,

    Unfortunately, this does not help.

    Have you received my email from the contact form last week?

    I did send you Credentials to the staging Website.

    Thanks in advance
    Marius

    #40516
    PeterPeter
    Moderator

    Hello,

    I have not received any email from you. Can you please resend it?

    #40530
    MariusMarius
    Participant

    Just send it via your contactform again.

    With Subject: Gutenberg Block with Relation does not work anymore

    #40554
    MariusMarius
    Participant

    Hi Peter,

    Did it reach you this time?

    Thanks in advance
    Marius

    #40576
    PeterPeter
    Moderator

    Hello,

    I'm sorry about that, there was an issue with our ticket system. Can you please send the info again?

    #40655
    MariusMarius
    Participant

    Just send it again.

    Thankfully, last time (2nd try), i saved the email-text 😉

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.