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:
- How to update custom fields using the wp_insert_post() function?
- Display all values of custom a field created with ACF on a page
- Adding custom input for data attribute in insert media modal
- If Custom Field is empty don’t display div
- Custom Meta Field – Youtube embed
- Print html when custom field has value inside while loop
- Update WordPress Custom Field with AJAX on cached page
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- get_post_custom single array
- Get only the grandchildren, not the direct children of page/current page?
- how to increase custom post value by one most efficiently?
- Sum custom field values of particular taxonomy
- Importing hard coded custom field into acf field
- Passing the custom field values in the wp_get_current_user array function
- How to hide all child pages with post_query?
- wordpress allow user to edit user profile with custom fields
- Firing schema via code in functions.php doesn’t work
- How can I add extra word in permalink when someone click download button?
- Seach custom post type posts only by meta fields?
- Child page menu in sidebar
- auto-populating custom nav with all items from custom post type
- conditional logic for front-end custom field edits
- Automatic Shortcode Creation with Custom Fields [closed]
- Custom field values to taxonomy terms
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- get_the_title() gets printed out twice
- Which PHP page is the Default Posts Page
- Saving zero in meta box
- Non-Closing PHP Query in WordPress Loop
- How to check if a PHP string is different than meta field?
- Display custom field on 404 page outside loop
- Why does this update_post_meta function not delete the custom field itself?
- How to show/hide php table rows based on the content of custom fields
- Only show image from custom field when present
- how to get serialized post meta
- Hide Heading if ACF Field is empty
- Custom meta box values are not getting saved for my custom post type
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Creating an image from a custom field
- User Meta Value not echoing despite Var_Dump Showing correct string
- WP All Import / Update stock quantity from multiple XML files
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Concatenate Custom Field Value & HTML Value
- Output custom text field as unordered list
- Conditional featured image with youtube thumbnail
- Order a WP_Query by meta value where the value is an array
- Unable to render custom field after attempt to generate a list of recent post in page template
- Add a custom class to the body tag using custom fields
- Conditional On custom field plugin metabox
- Display background color or image with custom meta box?
- Meta boxes only displayed when editing normal (default wp post_type) posts
- WordPress stripping out custom field tags
- Using an “IF” statement based on the existence of custom field
- Display additional user fields
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Updating Metadata with Shortcode
- How do you save the values from custom fields to a products data
- Add a “custom field” to a category that can be retrieved when viewing the category page with get_post_meta
- Trying to update Woocommerce meta values
- Is it possible to update the dataset using update_post_meta
- Setting up a cron job to auto update a custom field
- How to Call on WordPress Custom Fields without a Plugin
- Query on a repeater date (acf)
- Save custom field on WP_List_Table
- How do I get the value of a current user’s custom field?
- Trying to retrieve meta values from three different meta keys and display in rows
- WP post meta – for loop inside for loop
- custom fields anchor points php
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WooCommerce multiple custom fields code
- Updating Lat and Lng of posts automatically gives sporadic results
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- meta field for numerous links
- Custom fields changes the formatting of metabox input
- Include a custom field in mysql query
- Display Content Based on Custom Field Value
- divide custom field values in div every two values
- List of child pages fetch next results at link click
- Sidebar current menu item for parent
- Showing custom field contents without listing description
- How to exclude post from being queried based on custom meta value
- How to link a word comprised of a custom field with another?
- Custom field in title
- How can I put a custom field as the link of a button shortcode?
- I want Page titles and excerpts to show up on home.php in certain order
- Posts sortable column not sorting properly for custom field numbers
- Search result page – display values from the result’s metaboxes
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Appending an ACF custom field to the page title
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- I want to show image from custom field image on my custom page template
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- Custom Admin Menu Report for Specific User ID
- ACF number less than comparison not working