WordPress.org

Ready to get started?Download WordPress

Forums

Attachments
[resolved] new Attachments(instance,post_id) fails (3 posts)

  1. pborg
    Member
    Posted 1 year ago #

    Hi,

    Using latest version with wp3.5 to get attachments from post other than the current fails because:

    global $post;
                if( is_null( $post_id ) && is_object( $post ) && isset( $post->ID ) )
                {
                    $post_id = $post->ID;
                }
                elseif( isset( $_GET['post'] ) )
                {
                    $post_id = intval( $_GET['post'] );
                }
                else
                {
                    // no post ID, nothing to do...
                    return;
                }

    If post_id is set then this logic causes get_attachments to return as though no post id was set.

    Changed to

    global $post;
                if( is_null( $post_id ) && is_object( $post ) && isset( $post->ID ) )
                {
                    $post_id = $post->ID;
                }
                elseif( isset( $_GET['post'] ) )
                {
                    $post_id = intval( $_GET['post'] );
                }
                elseif (!isset($post_id))
                {
                    // no post ID, nothing to do...
                    return;
                }

    Works great (for me anyway, haven't done extensive testing....!)

    http://wordpress.org/extend/plugins/attachments/

  2. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    I believe I just saw a pull request for this issue. I'll make sure it's working in the next update. Leaving as unresolved until I fix it up. Thank you for the report!

  3. Jonathan Christopher
    Member
    Plugin Author

    Posted 1 year ago #

    This has been resolved in version 3.0.3

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic