【问题标题】:how to change page title in wordpress如何在wordpress中更改页面标题
【发布时间】:2018-03-09 16:26:23
【问题描述】:

我正在尝试更改我的 wordpress 网站页面的 the_title(),但它会更改所有文本,而我只是将“订单”更改为“报价”并留下订单号“#3344”。谁能帮助我的 if 语句。

<?php
// Changeing Order title to quote
    $page_id = get_the_ID();
if($page_id == '49')
    {
        $original_title = get_the_title();
        $new_title = str_replace("ORDER","QUOTE","ORDER");
    echo $new_title;
 }
    else {
        the_title();
        }
?>

【问题讨论】:

  • 这个问题应该重新制定,因为它实际上不是关于 wordpress 或 html 元素,而是关于 str_replace 函数。另外,请将新旧标题字符串分享给我们。

标签: javascript php wordpress function if-statement


【解决方案1】:

请仔细查看docs。但是 - 你必须使用 wp_title() 函数:

示例代码:

wp_title( string $sep = '&raquo;', bool $display = true, string $seplocation = '' )

参数:

$sep (string) (Optional) default is '»'. How to separate the various items within the page title.

$display  (bool) (Optional) Whether to display or retrieve title.

(string) (Optional) Direction to display title, 'right'.


我很确定wp_title 会做正确的工作:)

您可以在此处找到更多信息:!! hit me !!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    • 2017-05-06
    相关资源
    最近更新 更多