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 pull through page title depending on which radio button is selected on the specific page?
- How to update custom fields using the wp_insert_post() function?
- Most efficient way to add javascript file to specific post and/or pages?
- Display all values of custom a field created with ACF on a page
- Adding custom input for data attribute in insert media modal
- How to automatically apply woocommerce product title to all product images alt tags?
- Show content if parent page has children
- How to handle a custom form in wordpress to submit to another page?
- If Custom Field is empty don’t display div
- How to display multiple Post meta_key/meta_values by SQL query
- Custom Meta Field – Youtube embed
- 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
- How can i create a function to get youtube video time
- Getting movie and serial on actor page
- Sum All the Post Meta of Published posts of Current Logged in user
- 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
- Child and Parent Pages list of sub pages
- 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
- 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 display custom field from a gallery thumbnail?
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- How to use something like meta_query but for fields?
- meta field for numerous links
- My function echos only “array”
- Custom fields changes the formatting of metabox input
- Include a custom field in mysql query
- PHP: Why does my code work in index.php but not a widget?
- Display Content Based on Custom Field Value
- php if, else & custom fields – syntax error
- 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
- Sidebar current menu item for parent
- 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 custom field doesn’t exist, or exists and it’s true show title?
- How to link a word comprised of a custom field with another?
- Custom field in title
- If Elseif Query
- How can I put a custom field as the link of a button shortcode?
- Outputting a custom field in PHP
- Sorting Meta Fields?
- Custom fields randomly stop working
- Display selected parts from selected pages on the frontpage?
- Where can I find the code for the menu page meta boxes?
- How to echo a different field if another field is empty?
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- PHP Puzzle: Unique Styles with PHP loop
- 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
- Display custom meta box in my template file
- Query posts by custom fields (object post)
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Metadata on the WP_Post object
- Appending an ACF custom field to the page title
- Too many if’s and else if’s ?? – Must be better way [closed]
- Advanced Custom Fields Show PHP in Text Areas
- WP query with variables gives no result for specific user
- Grabbing value of input field inside of array
- Displaying custom meta box value in a custom post page
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Convert custom field date format to “WordPress default”
- I want to show image from custom field image on my custom page template
- 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?
- 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
- Shortcode Displays 2 times
- How to execute a shortcode within a custom field?
- ACF number less than comparison not working
- fetch from an external api call and display results in page
- Problem with custom user fields default value and retrieval
- Cannot Access ACF Field Values via my Plugin
- 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
- ACF block gutenberg aligncenter don’t work
- Display WooCommerce Order Custom Field In Template (HPOS)
- How can I display a layout differently depending on whether the user is on Mobile or PC?
- hide “Open in New Tab” checkbox in link field
- Want to add custom post type for facebook feed
- Exclude function for custom pages, exclude custom ACF fields
- Custom rest fields not loaded in rest api cpt response
- Display posts in correct month order using single date custom field