Skip Navigation

[Resolved] How to use value of CPT custom *field* as a term in permalink logic?

This thread is resolved. Here is a description of the problem and solution.

Problem:

The issue here is that the user wanted to add a custom field value to the post URL using the permalink settings

Solution:

Unfortunately this would require some amount of custom coding that would be out of the scope of our support forum.

What I recommend that you do is to contact one of our registered contractors for assistance with this one.

This support ticket is created 6 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 3 replies, has 2 voices.

Last updated by Shane 6 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#917906

I have a CPT: Project
One of the custom fields, slug, is: project-number

I would like to have permalinks like this:
../project/%project-number%/

How can I achieve this?
Thanks!

#917967

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

Thank you for contacting our support forum.

Unfortunately no this is not possible unless some custom code is used. Such custom coding is out of the scope of our support forum and as such i would recommend that you contact one of our registered contractors for assistance with this.
https://toolset.com/contractors/

Thanks,
Shane

#918349

Hi there Shane,
I'm not sure I understand why this is not possible...but I am finding it difficult to do.
Basically, I have imported those custom field contents into the default WordPress field for post_name

For example, my bulk content import has a column for projectnumber and there is a Types field for projectnumber.

Using a CSV importer, I have mapped the incoming column to both the WordPress field for post_name and the Types field for projectnumber.

In the permalinks, I have asked WP to give me a custom URL configuration like this:
../project/%postname%/

This format is displayed as the permalink, BUT the path does not resolve...a "nothing found" error is thrown.

If I change the permalink to:
../project-%postname%/ the URL resolves properly. I cannot understand this. If you are saying that's the way WP works, then yes, I will need a contractor. But it seems very odd that I cannot fix this though the admin UI.

Thanks for your further assistance.

#918382

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

You are saying that you've updated the post_name attribute in the DB with values from a custom field correct? This means that the %postname% should resolve to that value.

Could you try resaving one of the posts to ensure that the correct slug is displayed on the edit post page and then save it ?

Thanks,
Shane