How can I output the custom fields wrapping with HTML

There are many things in your code, I don’t know why you implemented like that. In my view the corrected code should be: <?php if ( get_post_meta( $post->ID, ‘the_link’, true ) != ” ) : ?> <span class=”the_one field1″> <a href=”https://wordpress.stackexchange.com/questions/125102/<?php echo esc_attr(get_post_meta( $post->ID,”the_link’, true )); ?>”> <b data-icon=”info” class=”inner-content”><?php echo _e( ‘Content’, ‘theme-text-domain’ ); … Read more

Conditional On custom field plugin metabox

This can’t work because isset() returns true if there is a value, trueand false are values, ergo it won’t work. Do it like this instead: $premium = get_field(‘premium’); if ( ! $premium ) { // this is basically short for $premium == false echo ‘not premium’; }

How to import database table as custom post type and custom fields?

// There’s a confusion in which method you are importing your external table into WordPress. If someway you have parsed you external table data into a PHP variable ex: $data, then it would be simple to import. foreach( $data as $_dt ) { $new_id = wp_insert_post( array( ‘post_type’ => ‘vehicle’, ‘post_status’ => ‘publish’, ‘post_title’ => … Read more

Help setting up a sql query

Ok, if i understand you clearly, then this is the solution // first get the post ids that have the breakfast food type $post_ids = $wpdb->get_col( “SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = ‘type’ AND meta_value=”Breakfast”” ); // now get the food names $stocktypes = $wpdb->get_col( “SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = … Read more

Comparing Dates from custom field

Well, the exact server time/timestamp can be retrieve with current_time function. And comparing your date format, it would need to be Ymd. So combining these two thing, the proper comparison for you should be – $key = get_post_meta( $post->ID, ‘Due’, true ); $date = date(‘Ymd’, current_time(‘timestamp’) ); if( $key >= $date ) { // note … Read more