【问题标题】:Option tree output not showing in theme option?选项树输出未显示在主题选项中?
【发布时间】:2016-04-07 19:01:10
【问题描述】:

我在我的 WordPress 主题中使用选项树。我正在尝试设置一个主题选项来上传图像以更改徽标图像。一切都已设置,但我正在使用此代码来显示输出,但它不起作用。我该如何解决这个问题?

<?php
    if ( function_exists( 'ot_get_option' ) ) {
        $images = explode( ',', get_post_meta( get_the_ID(), 'logo_image_url', true ) );
            if ( !empty( $images ) ) {
            foreach( $images as $id ) {
                if ( !empty( $id ) ) {
                    $thumb_img_src = wp_get_attachment_image_src( $id, 'logo-small' );
                    echo '<img src="'. $thumb_img_src[0].'" alt="" />';
                } //ENDIF EMPTY ID
            } //ENDFOREACH
        } //ENDIF EMPTY IMAGES
    } //ENDIF FUNCTION EXISTS
?>

【问题讨论】:

    标签: php wordpress options


    【解决方案1】:

    问题可能是 if 语句检查函数 ot_get_option。您没有声明或使用该函数,因此无需检查它是否存在。

    您还可以检查logo-small 是否是在add_image_size 注册的有效图像尺寸。

    【讨论】:

      猜你喜欢
      • 2012-09-17
      • 1970-01-01
      • 1970-01-01
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多