0

Next, I have a problem. I created a post_type = 'gallery'. So when I open my gallery my link goes like this:

localhost/gallery_name/image_name

but I need a structure like this:

localhost/post_name/gallery_name/image_name

In my function php

'rewrite' => array('slug' => '/',)

How can save my post name(my permalink structure) and then add gallery name and image name? Thank you.

1

You have to use post_type_link filter. Create a handler to handle this filter, you can create $permalink as per your need there.

In addition to this, you may have to use "pre_get_posts" action also.

I used both these couple of months ago, I created permalinks to show as cpt_name/post_name.

  • Well,my Wordpress cant recognize post i come from,before open gallery. I even tried some of plugins,and i realize that is a problem. If i could only insert post name into the array('slug' => '/',) that would be good. Thanks anyway – Djordje Maric Nov 14 '17 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.