【问题标题】:How to Change logo on the specific page of website in wordpress?如何在wordpress中更改网站特定页面上的徽标?
【发布时间】:2019-07-23 16:13:16
【问题描述】:

我正在使用 wordpress 开发一个网站。

我搜索了一个问题,即我希望使用任何插件在我的网站的一个页面中使用不同的徽标,但我没有找到令人满意的解决方案。

请有人告诉我如何做到这一点,主要标志应该出现在整个网站上,而辅助标志应该出现在我网站的一个页面上

【问题讨论】:

  • 您只能为该页面创建不同的标题。在该标题中您可以更改颜色徽标..然后转到页面,在 get_header() 中更改标题;
  • 请分享您主题中的 header.php 文件(显示徽标的位置),以便我们提供帮助。
  • 我的主题不允许我这样做。我没有使用 elementor。
  • header.php 没有显示在我的主题编辑器中

标签: css wordpress image


【解决方案1】:

如果你知道 wordpress 开发,你可以使用条件标签。 ref

【讨论】:

    【解决方案2】:

    您可以使用is_page()方法检查您所在的页面并相应更改徽标。

    因此,在标题或显示徽标的位置,您将这样做:

    <?php
    //Returns true when the Pages displayed is either post ID = 42, or post_name is "about-me", or post_title is "About Me And Joe".
    if(is_page( array( 42, 'about-me', 'About Me And Joe' ) ) )
    {
        //display the secondary logo
    }
    else
    {
        //display the main logo
    }
    

    当然我在这里假设您希望它与众不同的页面是 WordPress page

    如果是列表页面或单个帖子页面,那么您可以使用不同的检查方法。所有这些都被描述为here

    【讨论】:

    • 在 if 条件下我必须写什么。我是否必须编写代码背景:url(logo.gif");
    【解决方案3】:

    请将此代码插入到您的 header.php 文件中。

    $ss = $wp_query->post->post_title;
                        if($ss == 'your page name'){
                            echo '<img src="/your-new-logo.png" />';
                        }
                        else{
                            echo '<img src="/your-current-logo.png" />';
                        }
    

    【讨论】:

    • 我没有得到 header.php 文件.. 在主题编辑器中只是 function.php 文件显示:-|
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-29
    • 1970-01-01
    • 2017-03-06
    • 1970-01-01
    相关资源
    最近更新 更多