How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]

You can use get_field from ACF to check if the field is available and according to the documentation how you conditionally check if a field has contents. <div class=”wrapper”> <?php if (get_field(‘discount’)) { ?> <p>Discount: <?php the_field(‘discount’); ?></p> <?php } else { ?> <p>Price: <?php the_field(‘price’); ?></p> <?php } ?> </div><!–wrapper-end–> This should give you … Read more

shorthand syntax for custom fields

You have a couple of flaws in your code get_post_meta( ‘fap_referral_link’ ) should be get_post_meta( $post->ID, ‘fap_referral_link’, true ). Please see get_post_meta() You should always first check if you actually have posts before you run your foreach loop Never ever use extract(). It uses eval() which stand for EVIL. This has been completely removed from … Read more

Let user to add input fields on theme option page

You can do this by adding the following class in your theme for admin options; Custom-Metaboxes-and-Fields-for-WordPress And you can call your repeatable fields with some thing like this; array( ‘name’ => ‘Name of field’, ‘id’ => ‘prefix_option_name’, ‘type’ => ‘text’, ‘default’ => ”, ‘repeatable’ => true, ), For more details on how to use this … Read more

Get text from user and display it on page

go to your function php past this code function fb_add_custom_user_profile_fields( $user ) { ?> <h3><?php _e(‘Extra Profile Information’, ‘your_textdomain’); ?></h3> <table class=”form-table”> <tr> <th> <label for=”address”><?php _e(‘Address’, ‘your_textdomain’); ?> </label></th> <td> <input type=”text” name=”address” id=”address” value=”<?php echo esc_attr( get_the_author_meta( ‘address’, $user->ID ) ); ?>” class=”regular-text” /><br /> <span class=”description”><?php _e(‘Please enter your address.’, ‘your_textdomain’); ?></span> … Read more

Show custom field on attachment page?

If this is related to your other question then the custom field is attached to the post and not the attachment. You need to get the post ID of the post first then you can get the custom field. This should work. global $wp_query; $attachment_id = $wp_query->post->ID; $parent_id = get_post_field(‘post_parent’, $attachment_id); echo get_post_meta($parent_id, ‘my_custom_field’, true);

Get A Custom Field From A Custom Taxonomy Of A Custom Post Type [closed]

If you’r using ACF plugin you should look the documentation first, here’s relevant ACF saves taxonomies terms meta to options table, and they can be accesed using get_field( “{$field_key}”, “{$term->taxonomy}_{$term->term_id}” ); So in you’r example it would be: $image = get_field( ‘featured_image’, ‘product-category_’ . $product_category[0]->term_id );