我继承了一个菜单结构不起作用的网站。开发人员花费巨资建立了一个站点,但却留下了一个部分工作的站点。这是一个带有自定义模板的WooCommerce网站。我不明白这是怎么回事-非常感谢您的帮助。:-)
有问题的菜单是:
<form id="filter_dropdown_form" method="GET" action="http://www.punjaban.co.uk/wp-content/themes/punjaban/taxonomy-redirect.php">
<input type="hidden" name="post_type" value="product" />
<select name="term_filter" id="" class="turnintodropdown">
<option value="">Product Categories</option>
<option value="12">Accompaniments</option> <option value="20">Bread</option> <option value="9">Curry Bases</option> <option value="10">Pickles and Chutneys</option> </select>
<input type="submit" value="Filter" class="fallback" />
<input type="hidden" name="taxonomy_name" value="product_cat" />
</form>
这些类别都不起作用,将显示一个错误,建议对分类法重定向授予权限。php文件不正确(它是644)。
分类重定向。php:
<?php
require $_SERVER[ \'DOCUMENT_ROOT\' ] . \'/wp-blog-header.php\';
$term_id = $_GET[ \'term_filter\' ];
$url = \'\';
if ( $term_id !== \'\' ) {
$taxonomy_name = $_GET[ \'taxonomy_name\' ];
$url = get_term_link( intval( $term_id ), $taxonomy_name );
}
else {
$post_type = $_GET[ \'post_type\' ];
$url = get_post_type_archive_link( $post_type );
}
//$url .= \'#filter_anchor\';
wp_redirect( $url, 301 );
有两个文件称为分类法配方类别。php和分类库存商类别。php。代码如下:
application/x-httpd-php taxonomy-recipes-category.php ( PHP script text )
<?php
/**
* The template for displaying archive recipes.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package Punjaban
*/
get_header();
$post_type = \'recipes\'
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
get_template_part( \'template-parts/slider\' );
?>
<div id="content-section" class="<?php echo $post_type; ?>-loop-wrap text-center">
<div class="row">
<h2><?php the_field($post_type . \'_listing_title\', \'option\'); ?></h2>
<?php
if ( have_posts( ) ) {
$recipes_categories = get_terms(
\'recipes-category\',
array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => true,
)
);
$term_slug = get_query_var( \'recipes-category\' );
if (count( $recipes_categories > 0 ) ){
?>
<form id="filter_dropdown_form" method="GET" action="<?php echo get_stylesheet_directory_uri( ); ?>/taxonomy-redirect.php">
<input type="hidden" name="post_type" value="<?php echo $post_type; ?>" />
<select name="term_filter" id="" class="turnintodropdown">
<option value="">View Recipes With</option>
<?php
foreach( $recipes_categories as $recipes_category ) {
echo \' <option value="\' . $recipes_category->term_id . \'"\' . selected( $term_slug === $recipes_category->slug, true, false ) . \'>\' . $recipes_category->name . \'</option>\';
}
?>
</select>
<input type="submit" value="Filter" class="fallback" />
<input type="hidden" name="taxonomy_name" value="recipes-category" />
</form>
<?php
}
?>
<section id="isotope-container" class="isotope-wrap text-center">
<?php
$current_page = get_query_var( \'paged\' );
if ( !$current_page ) {
$current_page = 1;
}
$featured = get_field( \'featured_recipe_of_the_month\', \'options\' );
if ( !empty( $featured ) && $current_page == 1 ) {
get_template_part( \'listing-feat-\' . $post_type, \'\' );
}
while ( have_posts() ) {
the_post();
get_template_part( \'listing\', $post_type );
}
?>
<span class="clearboth"></span>
</section>
<?php
}
else {
//get_template_part(\'content\', \'none\');
echo \'<p>Sorry, no products here</p>\';
}
?>
</div>
<?php
if ( have_posts( ) ) {
global $wp_query;
echo TC_Library::get_paging( $wp_query->found_posts, $wp_query->query_vars[ \'posts_per_page\' ], array( ) );
}
?>
</div>
<?php
get_template_part( \'template-parts/cta\' );
?>
</main>
</div>
<?php
get_footer();
我认为每个pag都需要一个文件,对吗?例如,他们在博客和Woocommerce商店页面上有相同的类别下拉列表,但我看不到任何与此相关的代码。
该网站是www.punjaban.co.uk 非常感谢。