我已经安装了一个本地Wordpress,我试图让用户可以自定义它,所以它只显示他们选择的类别中的页面。我使用了在线程中找到的代码How to Set an Individual Homepage for Each User?当它工作时,它打破了每一页的菜单,它只是消失了。
前面的示例:https://i.stack.imgur.com/dVvLb.png
之后:https://i.stack.imgur.com/aNqWX.png
任何帮助都将不胜感激。提前谢谢你。
我已经安装了一个本地Wordpress,我试图让用户可以自定义它,所以它只显示他们选择的类别中的页面。我使用了在线程中找到的代码How to Set an Individual Homepage for Each User?当它工作时,它打破了每一页的菜单,它只是消失了。
前面的示例:https://i.stack.imgur.com/dVvLb.png
之后:https://i.stack.imgur.com/aNqWX.png
任何帮助都将不胜感激。提前谢谢你。
添加保护子句以防止修改其他查询很重要。(例如,菜单)。我们正在尝试修改这里的主查询,因此如果这不是主查询,我们应该退出。
function my_get_posts( $query ) {
// Bail if this is not the main query.
if ( ! $query->is_main_query() ) {
return;
}
// Other guard clauses to ensure we don\'t affect queries unintentionally.
// Sounds like you are just trying to target the homepage, so we could check for that too.
if ( ! is_home() ) {
return;
}
// We only need to modify the query for logged in users.
if ( ! is_user_logged_in() ) {
return;
}
// Modify the query as needed...
}
add_action( \'pre_get_posts\', \'my_get_posts\' ); // Note that pre_get_posts is an action, not a filter.
我试图用以下代码更改主页中的徽标链接:<?php echo esc_url( home_url( \'/home\' ) ); ?> 这在标题中。php但不起作用,我也尝试了add_filter( \'login_headerurl\', \'custom_login_logo_url\' );function custom_login_logo_url($url) { return \'/home\';} 不起作用。谢谢