Support » Plugin: Simple Custom Post Order » Ordering for custom posts in a custom gutenberg block

  • Resolved Bananenbiegerei

    (@bananenbiegerei)


    Hello,

    I am using the following setup:
    • a custom gutenberg block created with acf fields and registered in the function.php
    • the block uses a select field to filter for a custom post type
    • I want to display the selected post type ordered by Simple Custom Post Order
    • The Backend just works fine
    • But the frontend doesn’t show the order

    Here is the code for the loop in the gutenberg block:

    <?php
    $field = get_field_object( ‘post_type_loop’ );
    $value = $field[‘value’];
    $label = $field[‘choices’][ $value ];
    $column_count = get_field(‘column_count’);
    ?>
    <section id=”<?php echo esc_attr( $id ); ?>” class=”<?php echo esc_attr( $classes ); ?>”>
    <div class=”grid-x grid-margin-x small-up-1 medium-up-<?php echo $column_count; ?> block-grid padding-top-1 padding-bottom-2″>
    <?php
    $args = array(
    ‘post_type’ => array($value),
    ‘orderby’ => ‘menu_order’
    );
    $query = new WP_Query( $args );
    if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
    $query->the_post();?>
    <div class=”cell”>
    <?php
    if( get_field(‘display_options’) == ‘Simple’ ) {
    get_template_part(‘template-parts/content-simple’);
    }
    if( get_field(‘display_options’) == ‘Card’ ) {
    get_template_part(‘template-parts/card’);
    }
    ?>
    </div>
    <?php }
    } else {
    }
    wp_reset_postdata();
    ?>
    </div>
    </section>

    Here is a screenshot from the frontend:
    https://dev.iktf.berlin/wp-content/uploads/2021/05/Bildschirmfoto-2021-05-27-um-09.47.06.png

    And that is the backend:
    https://dev.iktf.berlin/wp-content/uploads/2021/05/Bildschirmfoto-2021-05-27-um-09.47.22.png

    I already tried to add ‘orderby’ parameter. But this doesn’t help.
    Thanks in advance

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.