Adding a metabox shortcode “paypal accept payment” in my custom post type back-end

Add this to your child theme / plugin functions.php. I think this should do the trick. Let me know function your_meta_callback( $post ) { echo Paypal_payment_accept(); } add_meta_box( ‘your_meta’, __( ‘Meta Box Title’, ‘your-textdomain’ ), ‘your_meta_callback’, ‘your-posttype-name’, ‘side’ ); For more information see WordPress Codex on add_meta_box(). Update: Ok I have looked into this. If … Read more

Error showing in current page id in wordpress admin

While front–end of the site always has a post context (you are either looking at one or archive of posts), admin side doesn’t. So plenty of admin screens won’t have $post global set to anything. You should be checking if it’s meaningful (for example by if ( ! empty( $post ) )) before trying to … Read more

Show button if meta box has content, else hide

Check to see if it’s empty before you show the div. <?php $true_title = get_post_meta( $post->ID, ‘true_title’, true ); ?> <?php if( ! empty( $true_title ) ) : ?> <div class=”discuss”><a href=”https://wordpress.stackexchange.com/questions/166858/<?php echo $true_title; ?>”>Discuss…</a></div> <?php endif; ?>

Meta Box multi checkbox in template

This will be made in the side of the template. First get all the sizes into an array: $allSizes = array( ‘XS’ => ‘Extra Small’, ‘S’ => ‘Small’, ‘M’ => ‘Medium’, ‘L’ => ‘Large’, ‘XL’ => ‘Extra Large’, ‘XXL’ => ‘Extra Extra Large’, ); echo ‘<ul>’; $outStock = get_post_meta($post->ID, ‘Sizes_available’, true); Then let’s compare if … Read more

Metabox not being added

That code doesn’t call the metaboxes of the good screen. Try this to call the metaboxes of the current screen. do_meta_boxes(”, ‘normal’, ‘saed’);

Front end post and upload file, image for users without plugin

Use wp_handle_upload in a custom function if ( $_FILES ) { upload_user_file($_FILES[‘test_upload’]); } if ( ! function_exists( ‘upload_user_file’ ) ) : function upload_user_file( $file = array(), $title = false ) { require_once ABSPATH.’wp-admin/includes/admin.php’; $file_return = wp_handle_upload($file, array(‘test_form’ => false)); if(isset($file_return[‘error’]) || isset($file_return[‘upload_error_handler’])){ return false; }else{ $filename = $file_return[‘file’]; $attachment = array( ‘post_mime_type’ => $file_return[‘type’], ‘post_content’ … Read more