Skip to content

Instantly share code, notes, and snippets.

@chikaibeneme
Last active April 3, 2025 13:35
Show Gist options
  • Select an option

  • Save chikaibeneme/d59d8e58396b71ad1842d2b65c740169 to your computer and use it in GitHub Desktop.

Select an option

Save chikaibeneme/d59d8e58396b71ad1842d2b65c740169 to your computer and use it in GitHub Desktop.
replace_organizer_slug_in_urls
<?php
// Force organizer post type slug to "ponent"
function modify_organizer_type_properties($properties)
{
$properties["rewrite"] = [
"slug" => "ponent",
"with_front" => false, // Optional: depends on your permalink settings
];
return $properties;
}
add_filter(
"tribe_events_register_organizer_type_args",
"modify_organizer_type_properties"
);
// Force rewrite rules to flush on plugin activation
function custom_events_calendar_rewrite_rules()
{
flush_rewrite_rules();
update_option("tribe_events_organizer_slug", "ponent");
}
register_activation_hook(FILE, "custom_events_calendar_rewrite_rules");
register_deactivation_hook(FILE, "flush_rewrite_rules");
// Replace all "/organitzador/" slugs in URLs dynamically
function replace_organizer_slug_in_urls($template_vars)
{
if (isset($template_vars["prev_url"])) {
$template_vars["prev_url"] = str_replace(
"/organitzador/",
"/ponent/",
$template_vars["prev_url"]
);
}
if (isset($template_vars["next_url"])) {
$template_vars["next_url"] = str_replace(
"/organitzador/",
"/ponent/",
$template_vars["next_url"]
);
}
return $template_vars;
}
add_filter(
"tribe_events_views_v2_view_organizer_template_vars",
"replace_organizer_slug_in_urls",
20
);
// Debug rewrite rules to ensure custom slug is applied
add_action(
"init",
function () {
error_log(
"Current Rewrite Rules: " .
print_r($GLOBALS["wp_rewrite"]->rules, true)
);
error_log(
"Organizer Slug Option: " .
get_option("tribe_events_organizer_slug")
);
},
20
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment