Posts that aren’t attached have no parent, and posts with no parent have a parent of 0.
So this:
if ( is_attachment() && isset( $post->post_parent ) && is_numeric( $post->post_parent ) && ( $post->post_parent != 0 ) ) {
becomes this:
if ( is_attachment() && ( $post->post_parent == 0 ) ) {
Related Posts:
- Display current category title on category page
- How to get the custom header image’s alt text?
- PHP unit testing WordPress?
- WordPress GET parameters causing 404 Not Found
- is_page() not working from within a plugin
- wp_set_object_terms and arrays
- How to create custom php script page
- Metabox repeating fields – radio buttons not saving correctly
- Create WordPress pages with PHP
- How do i hide the if the appears
- How to return the_excerpt (without echo)?
- How to handle a custom form in wordpress to submit to another page?
- Replacing mysql_real_escape_string in WordPress theme
- TCPDF get_post_meta outside the loop
- My shortcode is showing up twice
- Database “Migration” for Plugins?
- WooCommerce Link to Product Category
- Easiest way to show total number of subpages
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- How do I test PHP files in WordPress?
- ACF check if variable has http, if else return string
- Can’t load WP function into external function
- Woocommerce – Filter Variable Products by Variation Attributes and Variations Regular Price
- Loading header.php on specific page
- Adding a div at the bottom of a sidebar
- How can I set a default category for a custom post type in wordpress?
- how do I get a specific post from a post with a subcategory in WP
- PHP Fatal error: Out of memory in WordPress [closed]
- Theme developement – incative sidebars
- add_cap not working
- Styling my own password protected page, how to deal with wrong password?
- Help solving t_echo php error while using echo do_shortcode
- WordPress Theme Modification Help
- Hook called before text widget save
- How to list commenters and days since last commented
- PHP Warning: strip_tags() expects parameter 1 to be string?
- meta box not display data input in the textarea
- wpdb prepare insert table doesn’t work
- How to modify the default feed via a function
- dynamic page using php from sql database
- Automatically add images to a menu
- Store metakey value as an array
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- Custom Post type slider with thumbnail navigation
- Filter by field with array value in ACF on WP REST API
- how to add re-order to wp user panel of wordpress?
- How to add new CSS file to new PHP file
- custom plugin with upload files does not work
- WordPress SQL JOIN query
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- WP_Query and help with the loop for magazine front page
- Why does PHP called with Jquery AJAX not allow additional php code to be added?
- Infinite Loop in WordPress Installation
- send popup after wp_redirect()
- Validate search against a list of codes in wordpress
- Generating 10 000 WordPress posts using PHP and avoiding Server Timeout error
- A function to get the content of a page
- If Post Published Date or Modified Date is 1 Year or Older, Display Notice on Post Page
- Trying to create a shortcode to display categories with a specific product tag
- Using the get_template_part method within an mu-plugin not possible?
- Updating user meta adds string count to value?
- Woocommerce Product page add on checkbox and price
- Where Do Image Dimensions Get Added To A Filename?
- How to set Nav as a default menu in wordpress
- Sum All the Post Meta of Published posts of Current Logged in user
- Page template not working when logged out
- Add my footer menu to the header
- WordPress child theme, creating a custom php template page
- Child and Parent Pages list of sub pages
- How to block access to a folder inside of wp-content for non logged in users?
- Ordering / grouping posts by datepicker ACF
- How to use get_template_part always relatively to the file I’m using it in?
- Include search tags and users in my search results system
- Complex PHP for json_encode > how to handle/output right?
- Show content by using tags
- Return only certain (html)-elements of the_content()
- Only Get A Certain Number of Posts From WP_Query
- Need to adjust condition to say if I’m pulling categories from a post, to pull only the first one
- Showing featured image of page’s child’s children page
- Even with PHP plugin get_posts not working in widget area
- How to call post title and post summary to other part of site?
- how to run a php code in widget?
- how to add number value in front for variable [closed]
- Use custom get results query to show posts WordPress
- Execute php in pages
- Permission error on plugin save
- Display default WordPress login/registration form into a modal window
- Restricting Post Content Visibility with Custom Code – where to put it?
- WP Login Button for current domain
- How to NOT override inline css rules
- Adding Gravity Form With if(is_page) Is Not Working
- Implement “No related posts for this entry” into the loop?
- Twig+WordPress how to use array arguments inside a function?
- I would like to alert message while another user is editing or update data in wordpress admin panel, what should i do?
- save array of objects with update_option
- What is the best way to reset the site? Different fails while set up
- Themeco Looper Provider Query String for current user posts [closed]
- Remove colon from CTP UI “Singular Label”
- Customize create table SQL statement in any WordPress plugin