• Hello,

    I have a custom post type where each post has one image and on category. In a list I show all posts to the user that have the same category. In order to changes the categories easier I want to add a link to the list to open the image of the post in the medialibrarie grid view, that we all know and love. (Because the user can then see the image big and navigate to the next/prev image with the keyboard and change the category).

    Question 1: How do I create that link on my list to open the image directly in the grid view?

    Question 2: How can I “limit” the images in that grid view stream to show only images that have the same category as the original item that was used to open the grid view?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    I’m pretty sure the media library will not open for users that do not have the capability to edit the post. For such an interface you’ll need to build your own. You may be able to reuse parts of the media library to do so, but it’s probably not worth doing.

    When images are inserted, you have the option of what link to use with the image. The link to the attachment page should result in a decent sized image. The template for this can be altered to have custom nav links that lead where you want. It could also have a grid view link that goes to a page based on a custom template that displays images in a certain category.

    How this all works is mainly a matter of generating the correct query, roughly image attachments whose parent is in a particular category. This may require a custom mySQL query, I’m not sure conventional WP_Query arguments will do that unless the results are post processed by PHP. For example, get all image attachments. In the output loop, skip over any images whose parent is not in the current category. The problem with post processing is it makes pagination difficult.

    Thread Starter colibriinteractive

    (@colibriinteractive)

    Thanks @bcworkz I’ll try it with a custom solution then.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Open linked images of custom post type in medialibrary grid mode’ is closed to new replies.