Upload & include specific JavaScript files for posts?
Upload the file as media/attachment, add post meta data and add it as dependency to the footer via the Dependency API.
Upload the file as media/attachment, add post meta data and add it as dependency to the footer via the Dependency API.
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
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
More or less you got two decision points here. Are “types” of work items CPTs or terms of taxonomy? While from the start it sounds more like terms (they are all work items, but of different types) the latter requirement of different fields brings them closer to multiple CPTs in my opinion. I don’t think … Read more
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
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
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);
Custom fields are also known as post meta. Many things are stored as post meta, such as the ID of the featured image. You’ll have noticed that these do not show up in the custom fields section of your posts. This is because these post meta values have keys beginning with an underscore. Similarly any … Read more
You should be able to query ACF fields in the same way you query normal custom fields. With that in mind, you can do a simple meta_query to get a list of posts from the selected field You can try the following: $args = array( ‘post_type’ => ‘products’, ‘meta_query’ => array( array( ‘key’ => ‘stock’, … Read more
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 );