wpalchemy icon indicating copy to clipboard operation
wpalchemy copied to clipboard

Conflict With Custom Field Suite Plugin

Open jesserosenfield opened this issue 11 years ago • 1 comments

Adding the following code "breaks" the custom field suite plugin... any custom fields added with CFS disappear on that particular page editor (pages using the "landing.php" template) and you can't save new ones. Removing the following code makes the CFS fields visible again.

$featured_post_ids = new WPAlchemy_MetaBox(array ( 'id' => '_featured_posts', 'title' => 'Featured Blog Posts', 'context' => 'normal', // same as above, defaults to "normal" 'priority' => 'high', // same as above, defaults to "high" 'template' => get_stylesheet_directory() . '/metaboxes/full-meta.php', 'include_template' => array('landing.php') ));

jesserosenfield avatar Jul 18 '13 16:07 jesserosenfield

The issue was with the WP Alchemy repeating fields. Removing the the "foreach" loop solved the problem (but obviously took away the repeating fields). I set the "priority" to low and it solved the problem.

Although if I were to drag and drop the WP Alchemy meta box above the custom field suite boxes, the CFS boxes would break again.

So it appears there is a problem with the foreach() statement here: ( I also tried adding wp_reset_query() and rewind_posts() and no luck)

<a style="float:right; margin:0 10px;" href="#" class="dodelete-featured_posts button">Remove All</a>

<?php while($mb->have_fields_and_multi('featured_posts')): ?>
<?php $mb->the_group_open(); ?>

<label>Select a Post</label>
<?php $mb->the_field('featured_post'); ?>
<select name="<?php $mb->the_name(); ?>">

    <option value="">Select...</option>
    <option value="<?php echo $post->ID; ?>"<?php $mb->the_select_state($post->ID); ?>><?php the_title(); ?></option>
</select>

<?php $mb->the_group_close(); ?>
<?php endwhile; ?>

jesserosenfield avatar Jul 18 '13 16:07 jesserosenfield