programing

사용자 지정 로고 링크 변경 워드프레스

mailnote 2023. 10. 18. 22:57
반응형

사용자 지정 로고 링크 변경 워드프레스

워드프레스 로고 링크를 맞춤형으로 변경하려고 합니다.

내가 설정하고 싶은 새로운 링크가 http://newlink.html 이라고 하자.

저는 워드프레스 4.5.3을 사용하고 있고 주제는 스물다섯입니다.(따라서 사용자 지정 로고가 4.5에서 변경되었기 때문에 스택의 마지막 답변은 구식입니다.)

들어갔습니다.header.php발견된 항목:

twentyfifteen_the_custom_logo();

    if ( is_front_page() && is_home() ) : ?>
        <h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" 
            rel="home"><?php bloginfo( 'name' ); ?></a></h1>
    <?php else : ?>
        <p class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" 
            rel="home"><?php bloginfo( 'name' ); ?></a></p>
    <?php endif;

그러면 제가 정확하게 맞추면 함수를 호출하는 겁니다.twentyfifteen_the_custom_logo();사용자 지정 로고와 다음 두 링크는 텍스트 로고를 사용하고 있다면 영향을 주지 않습니다.

그 다음엔 사냥하러 갔습니다.twentyfifteen_the_custom_logo();변경할 수 있는 몇 가지 파라미터를 찾았습니다.

function.php:

/*
 * Enable support for custom logo.
 *
 * @since Twenty Fifteen 1.5
 */
add_theme_support( 'custom-logo', array(
    'height'      => 248,
    'width'       => 248,
    'flex-height' => true,
) );

그래서 저는 이런 것을 추가하는 아이디어를 얻었습니다.'src' => http://newlink.html,그러나 설명서는 이 매개변수를 수용하는 것처럼 보이지 않습니다.

나는 그 기능을 찾기 위해 사냥을 계속하고 있습니다.template-tags.php다음을 찾습니다.

if ( ! function_exists( 'twentyfifteen_the_custom_logo' ) ) :
/**
 * Displays the optional custom logo.
 *
 * Does nothing if the custom logo is not available.
 *
 * @since Twenty Fifteen 1.5
 */
function twentyfifteen_the_custom_logo() {
    if ( function_exists( 'the_custom_logo' ) ) {
        the_custom_logo();
    }
}
endif;

이 함수는 호출합니다.the_custom_logo();어디에서도 찾을 수 없는.

제가 뭔가를 놓쳤거나 잘못 본 것 같습니다. 사용자 지정 로고 링크를 사용자 지정 URL로 변경하는 방법을 찾아주시면 감사하겠습니다. :)

감사합니다!

WordPress 필터를 추가하여 사용자 지정 로고 링크를 다음과 같이 변경합니다.

당신의 것functions.php파일.

http://screencast.com/t/z19OejeBK

add_filter( 'get_custom_logo', 'wecodeart_com' );
function wecodeart_com() {
    $custom_logo_id = get_theme_mod( 'custom_logo' );
    $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
            esc_url( 'www.google.com' ),
            wp_get_attachment_image( $custom_logo_id, 'full', false, array(
                'class'    => 'custom-logo',
            ) )
        );
    return $html;   
} 

언급URL : https://stackoverflow.com/questions/38737209/change-my-custom-logo-link-wordpress

반응형