Wordpress更改特定页面的徽标

Wordpress更改特定页面的徽标,wordpress,header,Wordpress,Header,我正在使用wordpress,我想为两个特定页面设置不同的页面徽标 我创建了一个子主题,并在Functions.php文件中添加了以下代码: <?php if ( ! function_exists( 'wpex_header_logo_img' ) && is_page(877) || ! function_exists( 'wpex_header_logo_img' ) && is_page(970)) {

我正在使用wordpress,我想为两个特定页面设置不同的页面徽标

我创建了一个子主题,并在Functions.php文件中添加了以下代码:

        <?php

         if ( ! function_exists( 'wpex_header_logo_img' ) && is_page(877) || ! function_exists( 'wpex_header_logo_img' ) && is_page(970)) {
        function wpex_header_logo_img() {       

            // Get logo img from admin panel
            $logo_img = wpex_option( 'custom_logo', false, 'http://amcham2.amcham.gr/wp-content/uploads/2014/09/business-branding-identity.jpg' );

            // If logo URL isn't empty return the logo
            if ( '' != $logo_img ) {
                return $logo_img;
            }

            // Otherwise if logo is empty return nothing
            else {
                return;
            }}}?>

通过修改header.php文件中的logo部分(仅逻辑,缺少html代码):

通过functions.php文件中的原始函数(对问题的完整响应):


谢谢回答。我在header.php中将它改为这个:`if(!function_exists('wpex_header_logo_img')){function wpex_header_logo_img=wpex_option('custom_logo',false,'url');if(is_page(877)){$logo_img=wpex_option('custom logo_logo',true',)}或者if(is_page(970)){$logo_img=wpex_option('custom logo_logo',true'))}否则{return$logo_img;}}}}没有luckCheck再次检查我的回答。我也用你要求的功能更新了它。这应该没有问题;)
if ( ! function_exists( 'wpex_header_logo_img' ) ) {
    function wpex_header_logo_img() {



        // Get logo img from admin panel
        $logo_img = wpex_option( 'custom_logo', false, 'url' );

        // If logo URL isn't empty return the logo
        if ( '' != $logo_img ) {
            return $logo_img;
        }

        // Otherwise if logo is empty return nothing
        else {
            return;
        }

    }
}
  if ( is_page(877) ) {
     # Image for this page
  } else if ( is_page(970) ) {
     # Image for this page
  } else {
     # Default logo 
  }
if ( ! function_exists( 'wpex_header_logo_img' ) ) {
function wpex_header_logo_img() {

    if ( is_page(877) ) {
        $logo_img = 'Image path for this page image';
    } else if ( is_page(970) ) {
        $logo_img = 'Image path for this page image';
    } else {
        // Get logo img from admin panel
        $logo_img = wpex_option( 'custom_logo', false, 'url' );
    }

    // If logo URL isn't empty return the logo
    if ( '' != $logo_img ) {
        return $logo_img;
    }

    // Otherwise if logo is empty return nothing
    else {
        return;
    }
}
}