• Resolved jynk

    (@jynk)


    Great plugin solved a lot of issues.

    I was wondering if there’s a way to return an attachment’s parent post (if set) instead of the attachment.

    We want to search the tags of attachments and if matched then don’t return the attachment but the post id the attachment was uploaded to.

    Any help appreciated.

Viewing 1 replies (of 1 total)
  • Plugin Author Sumit Singh

    (@5um17)

    Hi,

    I am sorry but this plugin only returns actual post IDs. I will try to add some feature like this in future.

    For now you can edit the main loop and display the parent post content/title with few changes like this.

    
    if (get_post_type() == 'attachment') {
        global $post;
        $parent_post = !empty($post->post_parent) ? get_post($post->post_parent) : $post;
        
        echo get_the_title($parent_post);
    }
    

    If you place this code after the_post() then it will print the title of parent post for an attachment if exist.

    Hope this helps.

    Thanks

    • This reply was modified 5 years, 8 months ago by Sumit Singh.
Viewing 1 replies (of 1 total)

The topic ‘For matched attachments return parent if set’ is closed to new replies.