• Hey there,

    I was wondering if you had any idea why i’m getting this issue (below) where basically, I am creating a custom permalink structure for a post type of “hardware”. I then add the taxonomy into the url so the url reads for example http://example.com/hardware/servers/postname, servers being the taxonomy term.

    Here is the code where I create the permalink structure.


    function hardware_permalink_structure($post_link, $post, $leavename)
    {
    // If the post type isnt hardware return the link untouched
    if ($post->post_type !== 'hardware') return $post_link;

    // Get the terms for hardware_type
    $terms = wp_get_post_terms($post->ID, 'hardware_type');

    // If terms are empty then remove the hardware_type structure link
    if (!$terms) return str_replace('%hardware_type%/', '', $post_link);

    // IF we made it, replace the structure with the last term in the terms array
    return str_replace('%hardware_type%', array_pop($terms)->slug, $post_link );
    }
    add_filter( 'post_type_link', 'hardware_permalink_structure', 10, 3 );

    However this doesn’t work on the relevanssi search page and trying to get the terms for the post id given returns an empty array. I’ve tried a few alternative WP functions to get this working but to no avail yet =/.

    Would you have any idea why this is happening and or a relevanssi filter that could sort of achieve the same effect?

    Cheers,
    Luke

    https://wordpress.org/plugins/relevanssi/

Viewing 1 replies (of 1 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Relevanssi does adjust permalinks in the case of user profiles and taxonomy terms – but that doesn’t exist in the free version, so it’s not that.

    What your theme is using to display the permalinks on search results pages?

Viewing 1 replies (of 1 total)
  • The topic ‘Adjusting Permalinks’ is closed to new replies.