Find a way to retrive data updated through metabox plugin to web page

So finally I found a way to do that. Here is the code. page-contact.php <!– Contact Info –> <div class=”contact-info col-md-4 col-sm-4 margin-top-20 padding-left-20″> <label class=”contact-label pull-left width-wide”>Contact Info</label> <p><strong>IT’S SHOWTIME TOWING</strong><br /><br /> <!–Phone: <a href=”https://wordpress.stackexchange.com/questions/355497/tel:0450749863″>0450749863</a><br /><br /> –> Phone: <a href=”https://wordpress.stackexchange.com/questions/355497/tel:0450749863″><?php echo get_post_meta( $post->ID, ‘telNo’, true );?></a><br /><br /> <!–Email: <a href=”mailto:[email protected]”>[email protected]</a><br /><br … Read more

Creating custom meta box throws PHP warning error in WordPress

Because the third parameter/argument in the add_meta_box function expects a callback function name, which in your case as you have supplied is homepage_meta_box_display. However you still haven’t defined that function yet. The callback function is basically used to output the meta box content, anything that you would like to show up in the metabox you … Read more

Illegal string offset in PHP function

You need to be validating a couple of parts about $filearray before you use it. There are some good suggestions in the comments, I think a couple of robust examples would serve you well too: Using empty() function wp_custom_attachment() { wp_nonce_field( plugin_basename(__FILE__), ‘wp_custom_attachment_nonce’ ); $html=”<p class=”description”>Upload your PDF here.</p>”; $html .= ‘<input id=”wp_custom_attachment” name=”wp_custom_attachment” size=”25″ … Read more

Show meta box only for default page template

If the “Default Template” option is selected from the Template dropdown, then WordPress will set the value of the _wp_page_template meta to default and not page.php, so that’s most likely the reason why your meta box is not showing/added. So I would use if ( in_array( $pageTemplate, array( ‘default’, ‘page.php’ ) ) ) instead of … Read more

Finding the screen id of a page generated with add_menu_page

The function add_menu_page return the hook suffix that inform you about the current page. A simple example to get the hook suffix. public function add_menu_page() { $page_hook_suffix = add_menu_page( esc_html__( ‘Admin Page’, ‘translation-slug’ ), esc_html__( ‘Admin Page’, ‘translation-slug’ ), ‘read’, ‘My Name’, array( $this, ‘get_styles’ ) ); add_action( ‘admin_print_scripts-‘ . $page_hook_suffix, array( $this, ‘enqueue_assets’ ) … Read more

Have mu-plugin remove meta box ONLY if it isn’t already removed in functions.php

Hmm, a lazy workaround—as long as you’re not running PHP < 5.3.0—might be to use a namespace in your mu-plugins file. Something like this might do the trick: <?php namespace Arglebargle; \add_action( ‘wp_dashboard_setup’, ‘Arglebarle\remove_x_widget’ ); function remove_x_widget() { // If the meta box has already been removed, it shouldn’t be an // issue to ‘remove’ … Read more

add_post_meta() & update_post_meta()

add_post_meta() : Adds a meta field to the given post. Below is the example, <?php $post_id = 1; $meta_key = ‘_test’; $meta_value=”this is a test”; $unique = true; add_post_meta( $post_id, $meta_key, $meta_value, $unique ); update_post_meta() : if the given key already exists among custom fields of the specified post, another custom field with the same … Read more