Woocommerce - 未登录用户的“我的帐户”页面的替代h1标题

时间:2016-05-10 23:39:22

标签: php wordpress woocommerce account

我已经设置了我们的面包店网络商店,只有登录用户才能访问任何woo商业页面。现在我正在寻找一种方法来更改“我的帐户”页面上的h1标题,以便为未登录的用户显示不同的内容。有谁知道如何实现这一目标?感谢您的输入! Saludos!

2 个答案:

答案 0 :(得分:1)

Wordpress具有内置功能,可检查用户是否已登录。

<?php
    //Built in Wordpress function that checks if the user is signed in
    if ( is_user_logged_in() ) {
        //If the user is logged in
        echo '<h1>Logged in title</h1>';
    } else {
       //If user is not logged in
       echo '<h1>Not logged in title</h1>';
    }
?>

您需要通过覆盖它来修改Woocommerce模板。

Example: To override the admin order notification, copy: woocommerce/templates/emails/admin-new-order.php to yourtheme/woocommerce/emails/admin-new-order.php

答案 1 :(得分:1)

----(更新)----

我错了... Woocommerce我的帐户是一个页面<h1>page title</h1>是您网页的标题,因此您需要在主题中页面 wordpress 模板中进行更改(每个主题不同)和不在woocommerce模板中

在主题文件夹中找到此模板后,您将在<h1>page title</h1>周围的if语句中使用条件:

// When user is on my account page and not logged in
if (is_account_page() && !is_user_logged_in()) {
    echo '<h1 class="entry-title">'.__("My custom title", "the_theme_slug").'</h1>'; // My custom title
} else {
   the_title( '<h1 class="entry-title">', '</h1>' ); // the normal template title
}

这段代码只是一个更接近的例子,你需要稍微定制一下......

相关问题