Changing post content on save, using updated fields

Try to use the post object provided by the action as the second parameter instead of getting it from database: function change_event_slug_on_save( $post_id, $post ) { … } add_action( ‘save_post’, ‘change_event_slug_on_save’, 10, 2 ); With this you can remove the line $post = get_post($post_id); EDIT: Tribe Events Calendar has it’s own actions for saving an … Read more

WordPress menu permalink redirects to wrong page

Regenerate your permalinks. Resetting permalinks rebuilds your link structure for WordPress. Often, this process must be performed after migrating a WordPress website, or when troubleshooting 404 errrors. This is accompished by choosing a different permalinks setting, and saving it. Then putting the permalink setting back to the original setting and saving it again. This is … Read more

Force pretty permalinks?

Not exactly the solution you’re asking for, but here’s how I would deal with such problem… If your plugin needs permalinks to be turned on, then I would put some checks and display a notice, if they’re not turned on. I don’t think that plugin should force anything. There can be a lot of reasons … Read more

WordPress custom post type permalink: website.com/post-name/post-id

product/([0-9]+)?$ translates to product/ followed by any number or nothing (and nothing more, not even a trailing slash). This doesn’t sound like the thing you want to achieve. Instead, try the following function wpse33551_rewrites_init(){ add_rewrite_rule( ‘^([^/]+)/([0-9]+)/?$’, ‘index.php?post_type=artikelen&p=$matches[2]’, ‘top’ ); } which translates to: ^ start of the string (ie, there is nothing else in front) … Read more

how to add two same slug under two category?

Reason for such behavior lies in wp_insert_post function. When you look at its code, on line 3319 you’ll see this line: $post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent ); And what this function does is (straight from Codex): Computes a unique slug for the post, when given the desired slug and some post details. … Read more