WordPress.org

Support

Support » Plugins and Hacks » Hacks » from custom-post-type to edit-media and redirect to cpt on update/save

from custom-post-type to edit-media and redirect to cpt on update/save

  • I finally have a problem I’m unable to solve.

    I’ve build a custom post type into a plugin. You can add attachements (post-type==attachement) to this post type via the media library. Since the attachements meta-data is also used I thought it easy to also link directly to attachements edit page (get_edit_post_link($id)). That get_edit_post_link function indeed brings you to the ‘edit media’ page but when you push the update/save button you are redirected to the Media overview page. Off course in this case I would like it to redirect back to my custom post type.

    I’ve tried the add_filter(‘redirect_post_location’…) but appearantly it’s not working for post-type==’attachement’ (unfortunately there’s no docs on redirect_post_location).

    Does anybody have a solution? I was thinking somewhere along the lines of: get_edit_post_link($id).’&redir=’.$_SERVER[‘PHP_SELF’]

Viewing 1 replies (of 1 total)
  • A small change in media.php makes it work

    change media.php ln 39 : wp_redirect($location);
    to : wp_redirect(isset($_GET[‘redir’])?$_GET[‘redir’]:$location);

    But that’s just hacking the core… useless since I’m building a plugin…
    Maybe I should just forget it for now and post a ticket asking for a redirect_media_location filter.

Viewing 1 replies (of 1 total)
  • The topic ‘from custom-post-type to edit-media and redirect to cpt on update/save’ is closed to new replies.