0

I changed my taxonomy slug from singular to plural ("state" to states").

Ever since then my taxonomy has been broken. It used to say OTHER instead of the state name. Now my urls look like this Domain.com/location/%states%/post-name

Im using wp-types.com and their support has been EXTREMELY horrible. I barely even get a short useless response once every 4 days.

They provided me with this code for my themes function file (i placed it at the end):

add_filter('post_type_link', 'my_permalink_structure', 10, 4); function my_permalink_structure($post_link, $post, $leavename, $sample) { if ( false !== strpos( $post_link, '%states%' ) ) { $term = get_the_terms( $post->ID, 'states' ); $post_link = str_replace( '%states%', array_pop($term)->slug, $post_link ); } return $post_link; }

And it gives me this error:

Parse error: syntax error, unexpected T_FUNCTION, expecting T_STRING or T_VARIABLE or '$' in /home/content/33/8824133/html/wp-content/themes/education/functions.php on line 131

1 Answer 1

0

If the code above is how it is in your actual theme file, there are obvious errors (maybe it didn't post right here). Here is the fixed code:

<?php
add_filter('post_type_link', 'my_permalink_structure', 10, 4);
function my_permalink_structure($post_link, $post, $leavename, $sample) {
  if ( false !== strpos( $post_link, '%states%' ) ) {
    $term = get_the_terms( $post->ID, 'states' );
    $post_link = str_replace( '%states%', array_pop($term)->slug, $post_link );
    }
  return $post_link;
  }
?>

If that doesn't help perhaps a link to the entire code would help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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