Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Random string in permastructure
- * Use %state% and %city% in "Permastructure" settings
- */
- function pm_extra_permastructure_tags($default_uri, $native_slug, $post, $slug, $native_uri) {
- // Do not affect native URIs
- // Limit to 'product' post type only
- if($native_uri == true || empty($post->post_type) || $post->post_type !== 'product') { return $default_uri; }
- // Store post ID in a separate variable
- $post_id = $post->ID;
- // Get post location data
- $post_location = gmw_get_post_location_data($post_id);
- if(strpos($default_uri, '%state%') !== false) {
- // Use GeomyWP API to get the 'state' field
- // ...
- $state = '';
- $default_uri = str_replace('%state%', $state, $default_uri);
- }
- if(strpos($default_uri, '%city%') !== false) {
- // Use GeomyWP API to get the 'city' field
- // ...
- $city = '';
- $default_uri = str_replace('%city%', $city, $default_uri);
- }
- return $default_uri;
- }
- add_filter('permalink_manager_filter_default_post_uri', 'pm_extra_permastructure_tags', 3, 5);
Add Comment
Please, Sign In to add comment