• Resolved TimPowersDesign

    (@timpowersdesign)


    Hi,

    I updated to Meta Box 4.8.0 this morning and it caused all my custom field data to disappear from the site. I’ve had to revert to the previous version which works, as I use the custom fields to create “Buy” buttons for books.

    Please find the code below that I use. It suggests in the update notes that the old syntax will still work, and the syntax on the documentation page is exactly the same. Please let me know if I’ve done anything wrong? Note that the line of code to go in the functions file is in there, and I copied it fresh from the documents page. I’m also aware that sorting by custom field isn’t going to work like that, I’m still working on a fix for that, if anyone knows anything, I’d love to hear it.

    <?php
                    $args = array('category_name' => '1618centuries', 'tag_slug__and' => array('1618century'), 'orderby' => 'book_code', 'order' => 'ASC', 'posts_per_page'=> -1);
                    $postslist = get_posts($args);
                    foreach ($postslist as $post) :  setup_postdata($post); ?>
                        <div class="book-row clearfix ">
                            <div class="book-thumbnail">
                                <a href="<?php the_permalink() ?>"><?php the_post_thumbnail( $size, $attr ); ?></a>
                            </div>
                            <p class="code"><?php echo rwmb_meta( 'book_code' ); ?></p>
    
                            <p class="code"><em><strong><?php echo rwmb_meta( 'mycpt' ); ?></strong></em></p>
                            <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a>
                            <p class="author"><?php echo rwmb_meta( 'book_author' ); ?></p>
                            <p class="price">&pound;<?php echo rwmb_meta( 'book_price' ); ?></p>
                            <form action="form-action" method="POST">
                                <input type="HIDDEN" name="userid" value="9629947">
                                <input type="HIDDEN" name="product" value="<?php echo rwmb_meta( 'book_code' ); ?> <?php the_title();?>">
                                <input type="HIDDEN" name="price" value="<?php echo rwmb_meta( 'book_price' ); ?>">
                                <input type="HIDDEN" name="qty" value="1">
                                <input type="HIDDEN" name="return" value="clientwebsite">
                                <input type="HIDDEN" name="units" value="1">
                                <input class="cta" type="SUBMIT" value="Buy Now" name="SUBMIT">
                            </form>
                        </div>
                <?php endforeach; ?>

    I’m not sure if I need to say anything else, it should be enough to work on, but let me know if I need to say anything else.

    https://wordpress.org/plugins/meta-box/

Viewing 15 replies - 1 through 15 (of 45 total)
  • Plugin Contributor Manny Fleurmond

    (@funkatronic)

    Can you provide the code that sets up the meta box?

    I am having the same issues after the update. Code that worked previously seems unable to find the rwmb_meta function as function_exists('rwmb_meta') returns false.

    Plugin Contributor Manny Fleurmond

    (@funkatronic)

    Can you post your code NoxPointe and where you have placed it? rwmb_meta seems to work fine on a template.

    Thread Starter TimPowersDesign

    (@timpowersdesign)

    Hi Manny,

    What do you mean by “Can you provide the code that sets up the meta box?”

    The code in my OP is just one example of a number of separate templates that use the same code (but with different categories/tags) to display the custom fields (book_code, book_author, book_price) for each book.

    The code for the functions.php file is as follows

    rwmb_meta( $field_id, $args = array(), $post_id = null );

    This is in /inc/homepage_functions.php which is included in functions.php

    function get_program_highlights() {
    $highlights = false;
    if (function_exists(‘rwmb_meta’)) {
    $highlights = array();
    for ($i=1; $i <= 3; $i++) {
    $highlights[$i] = rwmb_meta(‘_vetmed_program_highlight_’ . $i);
    }

    }
    return $highlights;
    }

    Plugin Contributor Manny Fleurmond

    (@funkatronic)

    I’m trying to replicate your situation as close as possible, which means getting the meta box code so I can create that, add data then creating my own template based on your code to see what is going wrong.

    Using my own code I’m not getting any issues so I want to use your exact code so I can figure out whats wrong and fix it.

    Thread Starter TimPowersDesign

    (@timpowersdesign)

    Hi Manny,

    The code I posted in my first post is one example of where I use your plugin. I’ll provide an entire template code below. If you’d like to look at the site to see how it works, it’s kentrotman.co.uk

    <?php
    /**
    * The template for displaying a book category.
    *
    Template Name:New-Osprey
    */
    get_header(); ?>
    	<div class="main-content index">
    		<h2><?php the_title(); ?></h2>
    		<hr/>
    			<div class="book-row-container">
    				<?php
                    $args = array('category_name' => 'osprey', 'tag_slug__and' => array('osprey'), 'orderby' => 'book_code', 'order' => 'ASC', 'posts_per_page'=> -1);
                    $postslist = get_posts($args);
                    foreach ($postslist as $post) :  setup_postdata($post); ?>
                        <div class="book-row clearfix ">
                            <div class="book-thumbnail">
                                <a href="<?php the_permalink() ?>"><?php the_post_thumbnail( $size, $attr ); ?></a>
                            </div>
                            <p class="code"><?php echo rwmb_meta( 'book_code' ); ?></p>
    
                            <p class="code"><em><strong><?php echo rwmb_meta( 'mycpt' ); ?></strong></em></p>
                            <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a>
                            <p class="author"><?php echo rwmb_meta( 'book_author' ); ?></p>
                            <p class="price">&pound;<?php echo rwmb_meta( 'book_price' ); ?></p>
                            <form action="formaction" method="POST">
                                <input type="HIDDEN" name="userid" value="9629947">
                                <input type="HIDDEN" name="product" value="<?php echo rwmb_meta( 'book_code' ); ?> <?php the_title();?>">
                                <input type="HIDDEN" name="price" value="<?php echo rwmb_meta( 'book_price' ); ?>">
                                <input type="HIDDEN" name="qty" value="1">
                                <input type="HIDDEN" name="return" value="www.kentrotman.com">
                                <input type="HIDDEN" name="units" value="1">
                                <input class="cta" type="SUBMIT" value="Buy Now" name="SUBMIT">
                            </form>
                        </div>
                <?php endforeach; ?>
    					<!-- ? php endwhile; ? -->
    		</div>
    		<br/>
    		<h2>Previously Listed</h2>
    		<hr/>
    			<div class="book-row-container">
    				<?php
                    $args = array('category_name' => 'osprey', 'tag_slug__and' => array('prevlist'), 'orderby' => 'book_code', 'order' => 'ASC', 'posts_per_page'=> -1);
                    $postslist = get_posts($args);
                    foreach ($postslist as $post) :  setup_postdata($post); ?>
                        <div class="book-row clearfix ">
                            <div class="book-thumbnail">
                                <a href="<?php the_permalink() ?>"><?php the_post_thumbnail( $size, $attr ); ?></a>
                            </div>
                            <p class="code"><?php echo rwmb_meta( 'book_code' ); ?></p>
    
                            <p class="code"><em><strong><?php echo rwmb_meta( 'mycpt' ); ?></strong></em></p>
                            <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a>
                            <p class="author"><?php echo rwmb_meta( 'book_author' ); ?></p>
                            <p class="price">&pound;<?php echo rwmb_meta( 'book_price' ); ?></p>
                            <form action="formaction" method="POST">
                                <input type="HIDDEN" name="userid" value="9629947">
                                <input type="HIDDEN" name="product" value="<?php echo rwmb_meta( 'book_code' ); ?> <?php the_title();?>">
                                <input type="HIDDEN" name="price" value="<?php echo rwmb_meta( 'book_price' ); ?>">
                                <input type="HIDDEN" name="qty" value="1">
                                <input type="HIDDEN" name="return" value="www.kentrotman.com">
                                <input type="HIDDEN" name="units" value="1">
                                <input class="cta" type="SUBMIT" value="Buy Now" name="SUBMIT">
                            </form>
                        </div>
                <?php endforeach; ?>
    					<!-- ? php endwhile; ? -->
    		</div>
    <?php get_footer(); ?>

    Hope this is what you meant. Otherwise, aside from the small line in the functions.php file, I have done nothing else to make it work.

    Thanks

    Thread Starter TimPowersDesign

    (@timpowersdesign)

    Grrr although I had replied to you about 5 minutes ago, it appears to have not posted.

    So basically, here’s my template code. But I can’t think of anything else you would need, other than this template (which is one of many) and the one liner in the functions.php file, I haven’t needed to do anything else to make it work pre-update. The website is kentrotman.co.uk.

    You can see from the code below, the custom fields are book_code, book_price, book_author and mycpt.

    <?php
    /**
    * The template for displaying a book category.
    *
    Template Name:New-Osprey
    */
    get_header(); ?>
    	<div class="main-content index">
    		<h2><?php the_title(); ?></h2>
    		<hr/>
    			<div class="book-row-container">
    				<?php
                    $args = array('category_name' => 'osprey', 'tag_slug__and' => array('osprey'), 'orderby' => 'book_code', 'order' => 'ASC', 'posts_per_page'=> -1);
                    $postslist = get_posts($args);
                    foreach ($postslist as $post) :  setup_postdata($post); ?>
                        <div class="book-row clearfix ">
                            <div class="book-thumbnail">
                                <a href="<?php the_permalink() ?>"><?php the_post_thumbnail( $size, $attr ); ?></a>
                            </div>
                            <p class="code"><?php echo rwmb_meta( 'book_code' ); ?></p>
    
                            <p class="code"><em><strong><?php echo rwmb_meta( 'mycpt' ); ?></strong></em></p>
                            <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a>
                            <p class="author"><?php echo rwmb_meta( 'book_author' ); ?></p>
                            <p class="price">&pound;<?php echo rwmb_meta( 'book_price' ); ?></p>
                            <form action="formaction" method="POST">
                                <input type="HIDDEN" name="userid" value="9629947">
                                <input type="HIDDEN" name="product" value="<?php echo rwmb_meta( 'book_code' ); ?> <?php the_title();?>">
                                <input type="HIDDEN" name="price" value="<?php echo rwmb_meta( 'book_price' ); ?>">
                                <input type="HIDDEN" name="qty" value="1">
                                <input type="HIDDEN" name="return" value="www.kentrotman.com">
                                <input type="HIDDEN" name="units" value="1">
                                <input class="cta" type="SUBMIT" value="Buy Now" name="SUBMIT">
                            </form>
                        </div>
                <?php endforeach; ?>
    					<!-- ? php endwhile; ? -->
    		</div>
    		<br/>
    		<h2>Previously Listed</h2>
    		<hr/>
    			<div class="book-row-container">
    				<?php
                    $args = array('category_name' => 'osprey', 'tag_slug__and' => array('prevlist'), 'orderby' => 'book_code', 'order' => 'ASC', 'posts_per_page'=> -1);
                    $postslist = get_posts($args);
                    foreach ($postslist as $post) :  setup_postdata($post); ?>
                        <div class="book-row clearfix ">
                            <div class="book-thumbnail">
                                <a href="<?php the_permalink() ?>"><?php the_post_thumbnail( $size, $attr ); ?></a>
                            </div>
                            <p class="code"><?php echo rwmb_meta( 'book_code' ); ?></p>
    
                            <p class="code"><em><strong><?php echo rwmb_meta( 'mycpt' ); ?></strong></em></p>
                            <a href="<?php the_permalink() ?>"><h4><?php the_title(); ?></h4></a>
                            <p class="author"><?php echo rwmb_meta( 'book_author' ); ?></p>
                            <p class="price">&pound;<?php echo rwmb_meta( 'book_price' ); ?></p>
                            <form action="formaction" method="POST">
                                <input type="HIDDEN" name="userid" value="9629947">
                                <input type="HIDDEN" name="product" value="<?php echo rwmb_meta( 'book_code' ); ?> <?php the_title();?>">
                                <input type="HIDDEN" name="price" value="<?php echo rwmb_meta( 'book_price' ); ?>">
                                <input type="HIDDEN" name="qty" value="1">
                                <input type="HIDDEN" name="return" value="www.kentrotman.com">
                                <input type="HIDDEN" name="units" value="1">
                                <input class="cta" type="SUBMIT" value="Buy Now" name="SUBMIT">
                            </form>
                        </div>
                <?php endforeach; ?>
    					<!-- ? php endwhile; ? -->
    		</div>
    <?php get_footer(); ?>
    Plugin Contributor Manny Fleurmond

    (@funkatronic)

    Okay, but what kind of code are you using for the meta boxes? I need that part so I can create some data for the template.

    Thread Starter TimPowersDesign

    (@timpowersdesign)

    Oh I see, you want data input. Ok usually in book_code I’d have something like B002, book_price is 20.00 (e.g.) and book_author is something like FLEURMOND (M)

    mycpt isn’t an issue, that’s just a “notes” bit.

    Plugin Contributor Manny Fleurmond

    (@funkatronic)

    How are you creating your meta boxes? Using admin_init or the rwmb_meta_boxes filter?

    Plugin Author Anh Tran

    (@rilwis)

    Can you please update the Meta Box to 4.8.1? And post the code you used to register meta boxes?

    Thread Starter TimPowersDesign

    (@timpowersdesign)

    Hi Manny,

    As found in both code examples I have previously posted, this is how I get the meta box data to appear on the website.

    <p class="price">&pound;<?php echo rwmb_meta( 'book_price' ); ?></p>

    If this isn’t what you mean, you’re going to have to explain to me what you want.

    Thanks

    I have the same issue, too. I’ve updated to 4.8.1 and all my custom field data area disappeared from the site.

    I create the metabox with rwmb_meta_boxes filter.

    How resolve it?

    Thanks!

    Plugin Author Anh Tran

    (@rilwis)

    Hi, I have written a guide to fix the problem on metabox.io blog:

    https://metabox.io/steps-fix-problems-meta-box-4-8-0/

    Please follow these steps and let me know if it works.

    Thanks

Viewing 15 replies - 1 through 15 (of 45 total)
  • The topic ‘Update causes Meta tags to disappear’ is closed to new replies.