URL append code breaking permalinks

Home Forums Calendar Products Events Calendar PRO URL append code breaking permalinks

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1295552
    platformb
    Participant

    Hi,

    I use the following code to add a sku to the end of all products urls. However, it breaks the permalinks for the events, not showing any link both on the front end or back end to the specific event. Can you suggest why this breaks and a way to solve it?

    Here is the website: https://www.richardjuzwin.com.au
    Here is the events page: https://www.richardjuzwin.com.au/events/
    Here is the link to a product showing the sku on the end of the URL: https://www.richardjuzwin.com.au/product/sg-21dc-kgv-2/?sku=26900
    Have added an image to this post where can see the event permalink is empty.

    function append_sku_string( $link, $post ) {
    $post_meta = get_post_meta( $post->ID, ‘_sku’, true );
    if ( ‘product’ == get_post_type( $post ) ) {
    $link = $link . ‘?sku=’ .$post_meta;
    return $link;
    }
    }
    add_filter( ‘post_type_link’, ‘append_sku_string’, 1, 2 );

    #1297001
    Cliff
    Member

    Hi. Thanks for this detailed report.

    I rewrote this snippet for you. Please try it out (it’s untested):

    https://gist.github.com/cliffordp/ac089aa7a3cd509fc871b1e6bce11f7f

     

    Please know that we do not typically provide custom coding support like this, per our Scope of Support / Terms, but we like to go above-and-beyond from time-to-time.

    Please let me know how this goes for you.

    #1315935
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘URL append code breaking permalinks’ is closed to new replies.