$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>templates - is_tax not working for custom taxonomy|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

templates - is_tax not working for custom taxonomy

matteradmin8PV0评论

I am trying to over-ride a custom taxonomy file from my plugin. Actually, I have 2 custom taxonomies: destination & activities. I have successfully over-ridden the taxonomy template for activities but for destination is_tax() function is not working. That is why I am unable to over-ride the taxonomy template for destination. Everything including slug is absolutely correct. Tried this as well: Template redirect is_tax() not working On body tag, this is the class that is displayed on failed state: hfeed image-filters-enabled

Below is my function:

function abc( $template_path ) {
    if( is_tax( 'destination' ) )
    {
        $template_path = locate_template( array( 'taxonomy-destination.php' ) );

        // LOOK IN MAIN PLUGIN
        if( !$template_path )
        {
            $template_path = WP_TRAVEL_ENGINE_TEMPLATE_PATH . '/taxonomy-destination.php';
        }

        // OVER-RIDE FROM CURRENT PLUGIN
        if( $template_path )
        {
            $template_path = WP_TRAVEL_ENGINE_VENDOR_BASE_PATH . '/public/vendor-templates/page-templates/taxonomy-destination.php';
        }
        return $template_path;
    }
    if( is_tax( 'activities' ) )
    {
        $template_path = locate_template( array( 'taxonomy-activities.php' ) );

        // LOOK IN MAIN PLUGIN
        if( !$template_path )
        {
            $template_path = WP_TRAVEL_ENGINE_TEMPLATE_PATH . '/taxonomy-activities.php';
        }

        // OVER-RIDE FROM CURRENT PLUGIN
        if( $template_path )
        {
            $template_path = WP_TRAVEL_ENGINE_VENDOR_BASE_PATH . '/public/vendor-templates/page-templates/taxonomy-activities.php';
        }
        return $template_path;
    }
    return $template_path;
}
add_filter( 'template_include','abc' );

This is how taxonomy is registered:

$labels = array(
            'name'              => _x( 'Destinations', 'taxonomy general name', 'wp-travel-engine' ),
            'singular_name'     => _x( 'Destinations', 'taxonomy singular name', 'wp-travel-engine' ),
            'search_items'      => __( 'Search Destinations', 'wp-travel-engine' ),
            'all_items'         => __( 'All Destinations', 'wp-travel-engine' ),
            'parent_item'       => __( 'Parent Destinations', 'wp-travel-engine' ),
            'parent_item_colon' => __( 'Parent Destinations', 'wp-travel-engine' ),
            'edit_item'         => __( 'Edit Destinations', 'wp-travel-engine' ),
            'update_item'       => __( 'Update Destinations', 'wp-travel-engine' ),
            'add_new_item'      => __( 'Add New Destinations', 'wp-travel-engine' ),
            'new_item_name'     => __( 'New Destinations Name', 'wp-travel-engine' ),
            'menu_name'         => __( 'Destinations', 'wp-travel-engine' ),
        );

        $args = array(
            'hierarchical'      => true,
            'labels'            => $labels,
            'show_ui'           => true,
            'show_admin_column' => true,
            'rewrite'           => array( 'slug' => 'destinations','hierarchical' => true ),
        );

        register_taxonomy( 'destination', array( 'trip' ), $args );

Any help would be more than appreciable.

Post a comment

comment list (0)

  1. No comments so far