Add Segment to URL from Custom Field?

[ad_1]

I’ve hit a bit of a wall here. I need to take the value of a custom field (“id”) and insert it into the URL of a custom post type’s page (the CPT is “inventory-item”). The desired outcome is to have the URL structured as “domain.com/cars-for-sale/id/post-name.” The “Cars for Sale” component and “Post Name” components are already in place per how I set up the custom post type’s permalinks to work. I’m just really struggling with adding this ID segment.

Any thoughts?

[ad_2]
1 Comment
  1. Where you get your custom field from? If you’re using acf it easy as this:

    domain.com/cars-for-sale/<?php echo the_field( ‘id’ ); ?>/post-name

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer