Hello and thank you for the question.
We only provide support for individual permalinks in the Pro version. There you can configure any structure for the URLs of the posts under Settings > Permalinks.
Without the Pro version of the plugin, customizing the custom post type of the posts would only be possible through individual programming. WordPress offers corresponding hooks for this, e.g. https://developer.wordpress.org/reference/hooks/registered_post_type/ – however, as this represents an individual extension of the plugin’s options, we cannot provide any support for this.
Hi again,
thank you for helping out. We are using the pro version on a customer site, but configuring the URL structure does not ignore the individual structure. In our case:
WP individual URL structure: https://domain.tld/blog/%postname%/
Personio URL slug: career/jobs
Result: https://domain.tld/blog/career/jobs/
Goal: https://domain.tld/career/jobs/
For the moment I wrote this script to manually set the “with_front” argument of the “personiopositions” cpt to “false”:
// Sets with_front argument for CPT "personioposition" to "false"
add_action('init', function() {
if (post_type_exists('personioposition')) {
$args = get_post_type_object('personioposition');
if ($args) {
$args->rewrite['with_front'] = false;
register_post_type('personioposition', (array) $args);
// ONLY ONCE: Flush rewrite rules to apply changes
// flush_rewrite_rules(false);
}
}
}, 20);
This does work for the moment, although I don’t know if this can cause other internal problems and how reliable this is in terms of plugin updates. Is there a better solution for this?
Hello,
I can reproduce that in my case, but I would not like to implement this as a change in the plugin, because there are users who want to have /blog/ (or whatever they write there) in front of it. The individual solution with the code shown is a variant to solve this (I would only do without the permalink deletion, as it will never work there – flush_rewrite_rules() must be called via the wp hook).
Alternatively, it would also work like this (I assume this is a bit more performant):
add_filter( 'register_post_type_args', function( array $args, string $post_type ): array {
if( ! defined( 'WP_PERSONIO_INTEGRATION_MAIN_CPT' ) ) {
return $args;
}
if( WP_PERSONIO_INTEGRATION_MAIN_CPT === $post_type ) {
$args['rewrite']['with_front'] = false;
}
return $args;
}, 10, 2 );