[英]Wordpress category redirection and show post by specific category
I have added some categories in a menu. 我在菜单中添加了一些类别。 When I click on a category name in the menu I want to be redirected to a product page, and shown only the selected category product.
当我单击菜单中的类别名称时,我想重定向到产品页面,并且仅显示所选的类别产品。 How can I do this?
我怎样才能做到这一点? What should the post query be?
职位查询应该是什么?
You can do what you want by creating or modifying the template file category.php
, writing something like this : 您可以通过创建或修改模板文件
category.php
,编写如下代码:
<?php
$cat = get_queried_object();
wp_redirect( site_url('the-page-you-want').'#'.$cat->slug );
exit();
This will be redirect your category Example to : 这会将您的类别Example重定向到:
http://www.yourwebsite.com/the-page-you-want#example
Then you can use the hash in javascript 然后您可以在JavaScript中使用哈希
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.