How to write specific HTML code with a specific custom field? [closed]

Try this : // get_the_ID() will work if you’re running within The Loop. $fieldA = get_post_meta( get_the_ID(), ‘name_of_fieldA’, true ); $fieldB = get_post_meta( get_the_ID(), ‘name_of_fieldB’, true ); if( $fieldA ) { echo “<a href=””.$fieldA.”” target=”_blank” class=”btn btn-primary fb-event”></a>”; } if( $fieldB ) { echo “<a href=””.$fieldB.”” target=”_blank” class=”btn btn-primary ra-event”></a>”; }

Custom search SQL Query to add custom field in result

I got it ! Here is my final code for people who will search for similar problem 🙂 in functions.php : function se190254_custom_sql_for_search( ) { global $wpdb; //For security escape the search parameter $search_string = esc_sql($_GET[‘s’]); //Build the SQL request with $wpdb->base_prefix for “portability” $sql = “SELECT SQL_CALC_FOUND_ROWS {$wpdb->base_prefix}posts.ID FROM {$wpdb->base_prefix}posts LEFT JOIN {$wpdb->base_prefix}icl_translations t … Read more

How do I save Multiple fields in a meta box?

I would suggest you define a field names property on your class: class your_class { private $_fields = array( ‘firstname’, ‘lastname’, ‘sex’, ); public function prfx_meta_save ( $post_id ) { } } Now you can fully abstract your save handler: foreach ( $this->_fields as $field ) { if ( ! isset( $_POST[ $field ] ) … Read more