ACF true/false loop
-
Hola me encuentro con un problema
He creado un custom post type Portfolio en mi sitio y con ACF he creado cuatro campos adicionales: dos de imagen (“imagen” e “imagen_destacados”), un campo de texto “descripción” y un campo verdadero/falso (“selected”).
Y he agradado una taxonomía a el custom post type llamada “categoría” con cinco opciones.function create_posttype() { register_post_type( 'portfolio', // CPT Options array( 'labels' => array( 'name' => __( 'portfolio' ), 'singular_name' => __( 'portfolio' ) ), 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'portfolio'), ) ); } add_action( 'init', 'create_posttype' ); function custom_post_type() { // Set UI labels for Custom Post Type $labels = array( 'name' => _x( 'portfolio', 'Post Type General Name', 'calduchstudio' ), 'singular_name' => _x( 'portfolio', 'Post Type Singular Name', 'calduchstudio' ), 'menu_name' => __( 'portfolio', 'calduchstudio' ), 'parent_item_colon' => __( 'Parent portfolio', 'calduchstudio' ), 'all_items' => __( 'All portfolio', 'calduchstudio' ), 'view_item' => __( 'View portfolio', 'calduchstudio' ), 'add_new_item' => __( 'Add New portfolio', 'calduchstudio' ), 'add_new' => __( 'Add New', 'calduchstudio' ), 'edit_item' => __( 'Edit portfolio', 'calduchstudio' ), 'update_item' => __( 'Update portfolio', 'calduchstudio' ), 'search_items' => __( 'Search portfolio', 'calduchstudio' ), 'not_found' => __( 'Not Found', 'calduchstudio' ), 'not_found_in_trash' => __( 'Not found in Trash', 'calduchstudio' ), ); // Set other options for Custom Post Type $args = array( 'label' => __( 'portfolio', 'calduchstudio' ), 'description' => __( 'portfolio news and reviews', 'calduchstudio' ), 'labels' => $labels, // Features this CPT supports in Post Editor 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'revisions', ), // You can associate this CPT with a taxonomy or custom taxonomy. 'taxonomies' => array( 'category' ), /* A hierarchical CPT is like Pages and can have * Parent and child items. A non-hierarchical CPT * is like Posts. */ 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 5, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'page', ); // Registering your Custom Post Type register_post_type( 'portfolio', $args ); } /* Hook into the 'init' action so that the function * Containing our post type registration is not * unnecessarily executed. */ //* Link e4gf_events CPT to categories taxonomy add_action( 'init', 'sk_add_category_taxonomy_to_portfolio' ); function sk_add_category_taxonomy_to_portfolio() { register_taxonomy_for_object_type( 'category', 'portfolio' ); }
He creado el siguiente archive
<?php /** * * @author Ivan Ortiz & Xavier Guerrero Calduch */ //* Template Name: Portfolio //* The template for displaying the portfolio of our website. get_header(); ?> <div id="primary" class="content-area"> <main> <?php $args = array( 'post_type' =>portfolio, 'post_status' => 'publish' ); $query = new WP_Query( $args ); $i=0; if ( $query->have_posts()) : while ( $query->have_posts() ) : $query->the_post(); $selected = get_field('selected'); if($selected): $image = get_field('imagen_destacados'); if( !empty($image) ): ?> <article class="article-portfolio"> <a href="<?php the_permalink(); ?>"> <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> </a> </article> <?php endif; ?> <?php endif; ?> <?php endwhile; ?> <?php endif; ?> </main> </div> <?php get_footer(); ?>
El problema que encuentro es que a la hora de comprobar si el campo selected esta marcado o no hay algunas categorías que lo hacen y otras categorías que no.
¿Alguien podría decirme que puede suceder?
Viendo 5 respuestas - de la 1 a la 5 (de un total de 5)
Viendo 5 respuestas - de la 1 a la 5 (de un total de 5)
- El debate ‘ACF true/false loop’ está cerrado a nuevas respuestas.