Skip Navigation

[Résolu] Incorrect URLs when CPT single page has static parent

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created Il y a 10 années et 6 mois. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Asia/Manila (GMT+08:00)

This topic contains 9 réponses, has 3 voix.

Last updated by emerson Il y a 8 années et 11 mois.

Assisted by: emerson.

Auteur
Publications
#142901

I'm currently working on an animal rescue site that has animals available to sponsor on a monthly basis, as well as animals available to adopt.

I've created 2 custom post types, one is animals-adopt and one is animals-sponsor, to showcase individual animals.

In the main settings for each CPT, I've set the Post Relationship as Parent: Page.

On the individual custom post pages, in the Fields Table metabox where it says This CPT belongs to, I've set the "Sponsor" or "Adoptions" static pages as the parent page for each custom page.

My problem is that the permalinks aren't displaying correctly.

On the front end for user experience, what I'm trying to achieve is:

Desired URL structure: http:___.ca/our-work/adoptions/fluffy (Adoptions is the static parent page, Fluffy is the single CPT page)

However, what I have is:

Problem URL structure: http:___.ca/animals-adopt/fluffy (animals-adopt is the CPT slug)

Also, when I try the "quick edit" option for each single CPT page, the Parent shows as Main Page (no parent) rather than the static page I've assigned as the parent.

In the Edit Custom Post Type settings for animals-adopt, I tried the Use a custom URL format option, and put /our-work/adoptions/ in there. The internal links are coded correctly, but when I click through from the link on the static Adoptions page to the http:___.ca/our-work/adoptions/fluffy page, I get a 404 error.

What steps am I missing here?

#143360
adoptions.jpg
hierarchical.jpg
page-attributes.jpg
our-work.jpg

Dear Petra,
Thanks for the details. I did some tests and try out all possible combinations. The only that you can achieve your desired URL structure are as follows (try this in your test site or localhost):

Note: Before you proceed, make sure you start with a clean WP install so there should no old posts, pages or CPT.

a.) Create a custom post type "Our Works". see screenshot for the CPT name and slug setting. (our-work.jpg)
b.) Under "Display sections" of "Our Works" CPT setting, check "page-attributes". (see page-attributes.jpg).
c.) Under "Advanced" section of "Our Works" CPT setting, check "hierarchical". (see hierarchical.jpg)
d.) No need to set Parent and Child.
e.) Now click "Save Custom Post Type."
f.) In the admin menu, go to "Our Works" CPT and click "Add New".
g.) In the title, enter "Adoptions". The content of this is the same as your static Adoptions page before. Click Publish.
h.) Now, lets add the pet. Go to "Our Works" -- >Add New. In the title, enter "Fluffy".
i.) Enter the content for "Fluffy". Then in the "Attributes" section (found on the sidebar of the edit page), set the parent to "Adoptions".
See (adoptions.jpg)

j.) Click Publish. The URL structure of Fluffy is now your desired URL:
hidden link

You can do the same with sponsors, etc. Please let me know how it goes. Thanks.

Cheers,
Emerson

#143371

Thanks for the response, emerson!

Before I go ahead and implement your solution above, I have a couple questions:

1) In the existing site structure, which is 95% complete already, the current static "Our Work" page has 6 static pages under it already for various projects. Do I have to recreate all of those pages as CPT pages instead?

2) How do I transfer over all of the rest of my site that's already built out, without interfering with the CPT pages?

#143379

Dear Petra,
Thanks for the immediate feedback. Before making any changes like this, you need to make sure you have backup of your site so you can revert if needed. About your questions:

1.) If you have 6 pages under Our Work. Yes, you can add it as content under "Our Work" content post type as suggested. It will assume the URL structure like /our-work/this-is-your-other-static-page

This means re-creating the content under Our Work post type.

2.) I'm not sure about your other content as I don't have exact and detailed information about your site structure/content. The safest thing is to do this manually so you can be sure that it goes to the right pages and the right URL. This takes time, but I think this is the only I can think of that is safe.

Don't forget to always create a backup before making any major changes to your site 🙂

Cheers,
Emerson

#143385

One more question:

How/where do I add text content to the Our Work main overview page?

#143386

To further clarify - I don't want the /our-work/ page to contain the content excerpts of the CPT pages. On the existing site, the Our Work is an overview page with sections of static content describing each area of activity that the organization does. I don't want the /our-work/ to behave like an archive page for the CPT pages below.

#143394
has_archive.jpg

Dear Petra,
Yes, I think it is simple to fix. In your "Our Works" Edit custom post type configuration screen (in Types), uncheck " has_archive" under "Advanced" (see screenshot). This will prevent the "Our Works" CPT to have an archive. Then since the archived is disabled. You can create a normal page (Page -- Add New Page) with title "Our Work". You can then put your "Our Work" content there. The resulting URL will be /our-work/.
Then the rest will follow normally as I've suggested (your subpages,etc.). What will happen here is that you have the normal "Our Work" page: hidden link
While you have your subpages there that meets your URL structure requirement,e.g.

hidden link
hidden link

Please let me know how it goes. Thanks.

Cheers,
Emerson

#143524

Thank you emerson!

Everything is working the way I want it to now. I appreciate your help 🙂

#294481

Hi,

I've just been using this example but one thing isn't working how I expected.

I need to have archive pages for each part of the url, for example:

hidden link - would be a list of the work as an archive page (something I'm able to achieve)

hidden link - would show all the adoptions available as an archive page (currently this only shows it as a single page)

hidden link - would show the adoption as a single page (this is correct as it stands)

Is this possible?

Thanks

Scott

#294774

Dear Scott,
It depends on your post type. Say for example, your post type is 'Animals'. Archive page is accessible on this:
hidden link

One of the animal is birds. But birds is not another post type, its simply a page. It cannot be an archive.
hidden link

Also you can try using WordPress page attributes:
hidden link
In this case, you don't need to create a post type. Maybe you can achieve the URL structure that you want.
This thread is now marked as resolved by another user. To help you better and faster, please create a new ticket if you still need more help 🙂 Thanks.

Cheers,
Emerson

Le forum ‘Types Community Support’ est fermé à de nouveaux sujets et réponses.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.