[英]page for my custom taxonomy url link doesn't show up
Basically I have newsletter.php page where all the existing custom post are display.基本上我有 newsletter.php 页面,所有现有的自定义帖子都在其中显示。 from here, I have a dropdown category lists which you can filter the custom post by its category.
从这里,我有一个下拉类别列表,您可以按类别过滤自定义帖子。 once you click the specific category, it will proceed to pdf_cat.php to display the filtered output.
单击特定类别后,它将进入 pdf_cat.php 以显示过滤后的 output。 the problem is the result page item doesn't show up.
问题是结果页面项目不显示。 can you help me to figure it out the logic here?
你能帮我弄清楚这里的逻辑吗? here are my code so far:
到目前为止,这是我的代码:
from newsletter.php --> dropdown category button:来自 newsletter.php --> 下拉类别按钮:
<select name="form" id="form">
<div class="options">
<option value="<?php echo home_url('/newsletter'); ?>" selected>一覧</option>
<?php
$args = array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0,
'hide_empty' => false
);
$terms = get_terms([
'taxonomy' => 'pdf_cat',
'hide_empty' => false,
]);
foreach( $terms as $term ){
echo '<option class="ctg" value="'. get_term_link($term->term_id) .' ">' . $term->name . '</option>';
}
?>
</div>
</select>
My JS to fire the url link:我的 JS 触发 url 链接:
<script type="text/javascript">
$("#form").change(function(){
var url = $(this).val();
location.assign(url);
});
</script>
My pdf_cat.php page where the filtered result supposed to display:我的 pdf_cat.php 页面应该显示过滤结果:
<?php
$terms = get_the_terms(); // get the category from query
$terms = $term[0];
$term_name = get_term_name($term->name); // get the category name
$term_id = get_term_ID($term->term_id); // get the catehory ID
?>
<?php
$paged = get_query_var('paged', 1);
$args = array( // asigned the functions inside the array
'paged' => $paged,
'post_type' => 'pdf',
'taxonomy' => $term_id,
);
$query = new WP_Query($args); // get the functions inside the assigned name
global $query_string; //Post the specify numbers per page
query_posts( $query_string . "&posts_per_page=12&paged=".$paged );
while ( have_posts() ) : the_post()
?>
Can anyone help me to fixed this issue?谁能帮我解决这个问题? I hope this time I explain it clearly.
我希望这次我解释清楚。
You just need to change your pdf_cat.php to taxonomy.php and allow wordpress to open the taxonomy id link for you^^您只需将 pdf_cat.php 更改为 taxonomy.php 并允许 wordpress 为您打开分类 id 链接^^
check this link https://wphierarchy.com/检查此链接https://wphierarchy.com/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.