Custom Post Type not showing anything added by code anymore?
It wasn’t working because at public status draft/publish were written without a capitol so it has to be ‘post_status’ => ‘Draft’ or ‘post_status’ => ‘Publish’
It wasn’t working because at public status draft/publish were written without a capitol so it has to be ‘post_status’ => ‘Draft’ or ‘post_status’ => ‘Publish’
“Attachments” aren’t meta data. That is why you can’t retrieve them with get_post_meta(). “Attachments” are a post type that is attached to the parent post. You need to pull the attachment posts that have you post set as parent, and then use those IDs to get the attachment meta. $args = array( ‘post_parent’ => $post->ID, … Read more
Install metabox plugin and active: /**** Add this code in your function.php ****/ $meta_boxes[] = array( ‘id’ => ‘post_sidebar’, ‘title’ => ‘post Sidebar’, ‘pages’ => array(‘post’), ‘priority’ => ‘low’, ‘fields’ => array( array( ‘name’ => ‘Post Sidebar’, ‘id’ => ‘post_sidebar’, ‘type’ => ‘select’, “options” => array( “0” => “OFF”, “1” => “Left side”, “2” => … Read more
I am assuming that what you are trying to do is something like this: $artist_name = get_post_meta(get_the_ID(), “artist_name”, true); $args = array( ‘post_type’ => array(‘songs’), ‘meta_key’ => $artist_name, ); $related = new WP_Query($args); In your question you state that you want posts that “have same value of post meta with artist name”. What the code … Read more
I think you may need to add global $post after the loop starts based on a similar question found here. <?php while ($queryObject->have_posts()) { $queryObject->the_post(); global $post; ?> I wish I could explain more about why, but I didn’t have time to investigate further.
Problem solved. Added the following to my function: global $post;
The error message basically says that $wpdb is not an object so you can’t call any methods on it. As we can’t see where $wpdb is defined in the source you posted it’s hard to tell any further details. Are you even including wordpress in your external file? You need to require wp-load.php to use … Read more
I think what you are looking for is something like: <?php $post = get_post_meta($post->ID, ‘_cmb_fe_wysiwyg’, true) ; if (!empty($post)) { ?> <div id=”ingredientsNeeded”> <h3>Ingredients</h3> <?php echo wpautop( get_post_meta( get_the_ID(), $post . ‘_cmb_fe_wysiwyg’, true ) );?> </div> <?php } ?> This will check that the value is empty and if so will hide the div
It looks like the plugin is using the update_post_meta function, which in turn uses the update_metadata function which includes the action hooks update_postmeta and updated_postmeta which fire immediately before and after the post meta is stored to the database. You could hook into one of these to update the user meta of the author of … Read more
To get post meta fields, you can use get_post_meta() function, but obviously not get_user_meta(), the name of the functions are self-explanatory. The first parameter of get_post_meta() function is the post ID; here you define which post you want to get postmeta from. So, you need to get frist the post ID of the post you … Read more