I’m assuming there are only two children in such cases.
<?php
$child_id = $post->ID;
if ( $post->post_parent ) {
$args = array(
'post_parent' => $post->post_parent,
'post_type' => 'page',
'numberposts' => -1,
'post_status' => 'publish'
);
$children = get_children($args);
if(count($children) == 2) {
$child_id = $children[0]->ID == $post->ID ? $children[1]->ID : $children[0]->ID;
}
}
if ( get_field( 'show_video_menu' , $child_id ) ): ?>
<li><a id="artists-video" href="https://wordpress.stackexchange.com/<?php global $post;
if($post->post_parent) { $post_data = get_post($post->post_parent);
echo $post_data->post_name; }?>/video">Video</a></li>
<?php endif; ?>
Related Posts:
- Show content if parent page has children
- How to handle a custom form in wordpress to submit to another page?
- How to display multiple Post meta_key/meta_values by SQL query
- WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end
- How to make an meta_query optional?
- How to use multiple query with same meta key
- Easy way to process search results before displaying
- Getting movie and serial on actor page
- How to loop over custom fields in a page template?
- How can update custom meta for all posts
- Unique key for each row in a repeater field
- Removing WordPress profile fields from non-admins
- Use ajax to update_post_meta
- If Meta Checkbox is checked, do something?
- Show custom field if it exists, and show different elements if it doesn’t
- Custom field value not saving when it contains a URL?
- tracking number field in Woocommerce order [closed]
- How do I list the child of a child page [duplicate]
- How can I create a list of page titles from custom meta values?
- Sort posts by custom fields value using dropdown menu
- WordPress – Display array data of a child
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- Need Help Fixing My Iframes [closed]
- Adding number to date not working [closed]
- Saving and Restoring a Canvas on A Individual User Basis
- How to use thumbnail size of image if I’m only using src to get image
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- how to retrieve a value if a checkbox is checked
- Trouble checking if custom woocommerce checkout field is empty or not
- How do I Turn This Into An if statement?
- Add / Update Custom Fields After Select Pictures in Media Window
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Which PHP page is the Default Posts Page
- Remove the last X characters of a custom field value
- Non-Closing PHP Query in WordPress Loop
- Find a way to retrive data updated through metabox plugin to web page
- Why are the details of my todo not saving?
- Can’t save php string to a custom field
- How to show/hide php table rows based on the content of custom fields
- how to get serialized post meta
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- Handling repeater data
- How to add data to a custom field at the wp_users table?
- Conditional featured image with youtube thumbnail
- Add a counter for mouseovers (custom field)
- Including Custom fields within the_content
- How can i make a search box to search by custom field
- Show field if it has contents on Advanced Custom Fields
- the_meta – no get_the_meta query?
- Display Custom Field in Sidebar if Value is Present
- Using a string from a custom field within a link
- Make separate text boxes for separate WordPress Custom Fields
- Display additional user fields
- Dynamically added custom fields not displayed on WooCommerce email notifications
- How can I add diffrent editable text fields?
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Display custom field value in woocommerce variable product via jQurey
- Include custom fields in search
- update_term_meta() only updating once on certain meta keys
- Trying to update Woocommerce meta values
- How to Call on WordPress Custom Fields without a Plugin
- Query on a repeater date (acf)
- Generating 3 random numbers and saving them in database
- ACF – Can’t get custom post type by taxonomy
- Save custom field on WP_List_Table
- Sum All the Post Meta of Published posts of Current Logged in user
- Child and Parent Pages list of sub pages
- custom fields anchor points php
- When working with a post, almost all wp_postmeta are deleted
- What syntax is this? “{{post.price}}”
- Updating Lat and Lng of posts automatically gives sporadic results
- How to use something like meta_query but for fields?
- meta field for numerous links
- My function echos only “array”
- How to get the first letter from custom field?
- Meta box not saving spaces
- divide custom field values in div every two values
- List of child pages fetch next results at link click
- custom field meta-box with dropdown/autocomplete
- Showing custom field contents without listing description
- How to exclude post from being queried based on custom meta value
- If Elseif Query
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- Search result page – display values from the result’s metaboxes
- Display custom meta box in my template file
- Query posts by custom fields (object post)
- Too many if’s and else if’s ?? – Must be better way [closed]
- Advanced Custom Fields Show PHP in Text Areas
- Grabbing value of input field inside of array
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- How can I change the location where the custom field is displayed in the Quick Edit tab in WordPress
- How do I organize posts based on their taxonomy?
- Custom Admin Menu Report for Specific User ID
- Shortcode Displays 2 times
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- How to create advanced custom fields for backend content
- Want to add custom post type for facebook feed
- Exclude function for custom pages, exclude custom ACF fields