• Resolved launchinteractive

    (@launchinteractive)


    I have a custom post type (publications) with the following taxonomies which is working great:

    /publications/brochures
    /publications/articles
    /publications/policies
    /publications/reports

    I also have a few pages with the following slugs:

    /publications/forms
    /publications/performance

    The pages are showing a 404 because the tax doesn’t exist. Is there anyway to show the actual page without changing the url?

Viewing 1 replies (of 1 total)
  • Thread Starter launchinteractive

    (@launchinteractive)

    I’ve managed to get this working hooking into the pre_get_posts action…

    //load page when publication term doesn't exist
    function publications_page($query) {
    
        global $wp_query;
    
        if ( !$query->is_main_query() )
            return; 
    
    		if(is_tax() && isset($wp_query->query['publication']) && !term_exists($wp_query->query['publication'])) {
    
    			$page = get_page_by_path($_SERVER['REQUEST_URI'] );
    
    			if($page != NULL) {
    			  $wp_query = new WP_Query(array(
    			      'post_type' => 'page',
    			      'page_id' => $page->ID
    			  ));
    			}
    
    		}
    
    }
    add_action('pre_get_posts','publications_page');
Viewing 1 replies (of 1 total)
  • The topic ‘Force page for non found CPT taxonomy’ is closed to new replies.