Then you need a filter on the_content
.
function add_conditional_div($content) {
global $post;
$meta_field = get_post_meta($post->ID, 'your-field-name', true);
if (1 === $meta_field) {
$content .= '<div>whatever</div>';
}
return $content;
}
The 1
value, of course, is whatever should match your meta_field.
http://codex.wordpress.org/Function_Reference/get_post_meta
http://codex.wordpress.org/Function_Reference/the_content
You could also edit your theme files directly or make a child theme. The latter is highly encouraged if you are editing a theme you didn’t create.
Related Posts:
- Max length of meta_value
- The “_encloseme” Meta-Key Conundrum
- Filter WP_Query for posts having a certain meta-value
- Using get_post_meta with new_to_publish
- How to access custom order item meta data from a meta key in WooCommerce?
- Save HTML formatted data to post meta using add_post_meta()
- Plugin to auto convert custom fields to tag
- Order by Custom Field date not recognized
- How do I read the value of a custom field of the page?
- Display custom field only if value present?
- Advice needed for importing custom field data and database structure
- How to save multiple metaboxes?
- Displaying additional User Contact Information
- get_post_meta in sitewide tags plugin fails to return value for custom fields
- Making custom field’s ‘Name’ available in the dropdown list by default in a theme?
- meta_value_num sort glitch
- Populate Custom Field Dropdown on Theme Install?
- WooCommerce conditional required checkout fields [closed]
- Make URL in custom field hyper link
- meta query not showing any results?
- Using more than one meta_key in pre_posts_query
- meta_query for a string inside a meta field containing a comma-separated list
- Way To Store Global Meta Values
- Combine multiple custom field values into single value
- Creating a custom menu/widget area
- Orderby custom field meta value ASC and then by date DESC
- Can’t get post ID using wp_insert_post_data
- query usermeta from custom field
- Creating author profiles with extra fields and exporting that data?
- Modifying custom order item meta from admin order view
- Let users track progress by entering a number daily in profile?
- WooCommerce – Adding Custom Fields To Invoice
- Changing themes… and need to move Custom Field content into another field
- Filter Posts on Custom Fields and Show them on a new Page
- Removing link ” from ” on meta_value in custom feilds
- How to add a custom field in the advanced menu properties?
- $form_fields from attachment_fields_to_edit returning empty array
- How to link keywords in custom fields?
- Meta query with multiple custom fields for archives page ordering problem
- filter custom field values $min $max
- Customizing WP user profile with custom fields
- Custom Fields – How to create a list from multi-line entries of a single value
- Adding custom field to post object from custom table
- Auto embeding Vimeo/Youtube in custom fields (tinyMCE editor)
- How do I use “if field exists” with $curauth?
- Using abs() with custom field in orderby statement
- Can’t save custom field on registration page
- Read more to open external link
- Custom metabox not displaying multiselect data in edit mode
- How to validate select field in post meta?
- check for duplicate user meta data before updating
- WP Cli – post add meta in xargs after wp post generate – add multiple fields
- Anyone know how to use ACF and show custom fields for logged in users only on a post? [closed]
- How to redirect to home page according to a specific page custom fields value and user name
- How to use pre_get_posts to alter posts_per_page of category pages, where ‘posts_per_page’ will be dynamic
- How to print the Custom fields values [closed]
- How to validation for sanitize_URL?
- How can I output the custom fields wrapping with HTML
- custom field in admin columns
- Custom metabox not working
- How to get custom image field of specific post id
- Populate wordpress menu with link to custom field value (file download)
- Selectively hiding or allowing thumbnails of featured images on front page
- wp_get_attachment_image_src() with advanced custom fields returning empty
- Users uploaded image and matching an id or taxonomy
- Adding data to User profile
- How can I change author of posts to the value of one of the custom field of the posts?
- Woocommerce products search with custom fields
- Convert author metadata to a custom field
- Custom pages or Custom Posts
- get_avatar filter is not working as per requirement
- Is it possible to add Term Meta Fields to a WooCommerce Attribute?
- Saving Custom Field that includes Quotation marks
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- how to execute custom field for structured data?
- Saving custom form data
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- register_form, custom field not submitted on first try
- How to properly get popular Posts by multiple Values
- Echo out custom fields in comments
- Why WordPress takes time to make request to save post?
- Show comon custom field results?
- Query Custom Fields in Searchform
- Make custom user_meta as permalink for post
- Creating Structured Documents (books) in WordPress?
- Filter query based on date in custom field
- Display Child Page with custom fields within Parent Page
- Convert all dates in field to Unix time, except those already in Unix time
- Convert many posts from having a specific meta_key to use a post_format
- Custom fields: my custom checkbox area doesn’t seem to work
- get_post_custom_values not working
- Pagination not displaying correct number of pages
- How to include custom field in shortcode (do_shortcode) in theme file
- Query posts by Custom Meta (checkbox) & Genesis Grid Loop
- custom field with links
- How to get all specific fields from one ACF Group?
- Set new url from custom post field
- acf field repeater link don’t work
- Set post status to draft after validating post meta values in save_post hook
- get Custom field label (select/dropdown) on front end