• Resolved Jason Ryan

    (@viablethought)


    Hello –

    Saw someone else had posted a similar question. The permalink structure is severely flawed with MEC whereas it doesn’t allow for the correct permalink for archive pages or single events.

    I have it set to Custom Structure in my Settings like so for Blog Articles:
    /press/%post-name%/

    But when you click on a Single Event, the permalink looks like this:
    /press/events/name-of-the-event/

    Whereas it should just be:
    /events/name-of-the-event/

    I tried using the Custom Post Type Permalinks plugin as suggested by you in the other post, but it doesn’t allow you to edit anything in the permalink structure previous to:
    /press/events/

    I have used other calendar plugins that don’t do this, so I know it is possible, additionally have created hundreds of our own Custom Post Types where it doesn’t do it as well.

    What is the workaround for this to fix MEC’s permalink structure?

    Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter Jason Ryan

    (@viablethought)

    I found my own solution here:

    Modify Registered CPT

    What I changed:

    /**
     * Filter the Products CPT to register more options.
     *
     * @param $args       array    The original CPT args.
     * @param $post_type  string   The CPT slug.
     *
     * @return array
     */
    function custom_mec_event_permalink( $args, $post_type ) {
      // If no MEC Events CPT, bail.
      if ( 'mec-events' !== $post_type ) {
        return $args;
      }
      // Add additional Products CPT options.
      $event_args = array(
        'rewrite' => array(
            'slug' => 'events',
            'with_front' => false,
        )
      );
      // Merge args together.
      return array_merge( $args, $event_args );
    }
    add_filter( 'register_post_type_args', 'custom_mec_event_permalink', 10, 2 );

    Thanks

    Plugin Contributor webnus

    (@webnus)

    Hello @viablethought,

    Thank you for your report, it will be fixed in the next updates.

    Best Regards

    @viablethought — just ran into this problem myself, and really appreciate you sharing the solution here–that was very helpful!

    @webnus — a friendly reminder to please fix this in your next update!

    Thread Starter Jason Ryan

    (@viablethought)

    @hastibe

    No problem. These are slow to fixing things so most of the time you have to fix things yourself ??

    J

    I have the same problem and i have added above code on function.php but when i going on event single page it showing 404 error means page not findout.
    So please tell me why this is occuring.

    https://cpinj.staging.wpengine.com/blog/events/daily-each-3-days/
    See abpve url i want to remove /blog/ from this single event peremalink therefor i have added above code but not working.
    Please tell me solution for this.

    Thread Starter Jason Ryan

    (@viablethought)

    @roshankhan

    The “with_front” => false should remove /blog/ from the permalink, did you flush your permalinks? Flush your permalinks by going to Permalinks and just simply re-saving.

    Yes, Now it is working.
    Thanks, @jason Ryan

    I was also looking for this, super useful, thank you!

    Another thing to consider is that the $args have ‘archive” simply set to true. In that same hook you could also specify a specific archive URL:

    $args['has_archive'] = 'events';

    Hopefully these kind of settings get added to future versions. I’m tired of using Tribe Events and desperately need a solid alternative…

    The code worked great except for the breadcrumb link.

    https://website.com/ events / event

    When I click on events in the breadcrumb it still goes to the default permalink setting which in my case is /blog/events and since the page is no longer there I get a 404 error.

    I fixed this using Redirection but would prefer some code if anyone can suggest a fix.

    Thread Starter Jason Ryan

    (@viablethought)

    @dltampa

    Maybe try using the Custom Post Type Permalinks plugin? Depends on how your breadcrumbs are setup or configured.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Fixing Events Permalink’ is closed to new replies.