ruditrip27
Forum Replies Created
-
any advice on how to roll back to previous versions of UM?
Experiencing many issues with UM 2.0.9. my advice dont update!! my page in wp-admin just load and load and never complete. Definately related to UM because when i deactivate the plugin they load fine, Anyone else having same issue?
Forum: Plugins
In reply to: [WP Job Manager] Adding Category/Region to URL makes Blog Posts 404i am using the following code as suggested and listing url work fine with category/region/listing-name however i get the strange assorted of blog posts on every other page other than listing/category pages with the heading blog… am stumped…
function job_listing_post_type_link( $permalink, $post ) {
// Abort if post is not a job
if ( $post->post_type !== ‘job_listing’ ) {
return $permalink;
}// Abort early if the placeholder rewrite tag isn’t in the generated URL
if ( false === strpos( $permalink, ‘%’ ) ) {
return $permalink;
}// Get the custom taxonomy terms in use by this post
$categories = wp_get_post_terms( $post->ID, ‘job_listing_category’, array( ‘orderby’ => ‘parent’, ‘order’ => ‘ASC’ ) );
$regions = wp_get_post_terms( $post->ID, ‘job_listing_region’, array( ‘orderby’ => ‘parent’, ‘order’ => ‘ASC’ ) );if ( empty( $categories ) ) {
// If no terms are assigned to this post, use a string instead (can’t leave the placeholder there)
$job_listing_category = _x( ‘uncategorized’, ‘slug’ );
} else {
// Replace the placeholder rewrite tag with the first term’s slug
$first_term = array_shift( $categories );
$job_listing_category = $first_term->slug;
}if ( empty( $regions ) ) {
// If no terms are assigned to this post, use a string instead (can’t leave the placeholder there)
$job_listing_region = _x( ‘anywhere’, ‘slug’ );
} else {
// Replace the placeholder rewrite tag with the first term’s slug
$first_term = array_shift( $regions );
$job_listing_region = $first_term->slug;
}$find = array(
‘%category%’,
‘%region%’
);$replace = array(
$job_listing_category,
$job_listing_region
);$replace = array_map( ‘sanitize_title’, $replace );
$permalink = str_replace( $find, $replace, $permalink );
return $permalink;
}
add_filter( ‘post_type_link’, ‘job_listing_post_type_link’, 10, 2 );function change_job_listing_slug( $args ) {
$args[‘rewrite’][‘slug’] = ‘/%category%/%region%’;
return $args;
}
add_filter( ‘register_post_type_job_listing’, ‘change_job_listing_slug’ );
function add_category_endpoint_tag() {
add_rewrite_tag( ‘%category%’, ‘([^/]*)’ );
}
add_action( ‘init’, ‘add_category_endpoint_tag’ );function add_region_endpoint_tag() {
add_rewrite_tag( ‘%region%’, ‘([^/]*)’ );
}
add_action( ‘init’, ‘add_region_endpoint_tag’ );