【问题标题】:WordPress PHP - Hyperlink on imageWordPress PHP - 图像上的超链接
【发布时间】:2016-09-04 20:27:45
【问题描述】:

首先抱歉,如果这是一个简单的问题,这是我第一次使用 html / word press,这只是一个学习练习

基本上我已经在 word-press 上下载了 lawia lite 主题,在这个主题中,他们在主页上有三个图标,下面有文字,我想做的是让它让用户可以点击图像并被带到另一个页面,但是在主题的自定义选项中这是不可能的。

我想我已经找到了与此相关的 php,下面,我的问题是如何修改它以实现我的目标?

                    <?php
                        if ( get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_icon',get_template_directory_uri().'/images/features-box-icon-one.png' ) ) { 

                            echo '<div class="features-box-icon">';


                                echo '<img src="'.get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_icon', get_template_directory_uri().'/images/features-box-icon-one.png' ).'" alt="'.get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_title' ).'" title="'.get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_title' ).'" ;/>';

                            echo '</div>';
                        }

                        if ( get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_title','Lorem' ) ) {

                            echo '<h4>';

                                echo get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_title','Lorem' );

                            echo '</h4>';   
                        }

                        if ( get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_content','Go to Appearance - Customize, to add content.' ) ) {

                            echo '<p>';

                                echo get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_content','Go to Appearance - Customize, to add content.' );

                            echo '</p>';    
                        }
                    ?>
            </div><!--/div .features-box-->

我已经把它缩小到这行代码:

                                echo '<img src="'.get_theme_mod( 'lawyeria_lite_frontpage_secondlybox_icon',get_template_directory_uri().'/images/features-box-icon-two.png' ).'" alt="'.get_theme_mod( 'lawyeria_lite_frontpage_secondlybox_title','Ipsum' ).'" title="'.get_theme_mod( 'lawyeria_lite_frontpage_secondlybox_title','Ipsum' ).'" />';

我已经尝试添加一个 href

echo '< href="page.php" 'img src="'.get_theme_mod( 'lawyeria_lite_frontpage_secondlybox_icon',get_template_directory_uri().'/images/features-box-icon-two.png' ).'" alt="'.get_theme_mod( 'lawyeria_lite_frontpage_secondlybox_title','Ipsum' ).'" title="'.get_theme_mod( 'lawyeria_lite_frontpage_secondlybox_title','Ipsum' ).'" />';

但这会给出 HTTP ERROR 500

非常感谢

【问题讨论】:

    标签: php html wordpress


    【解决方案1】:

    看来我走在正确的轨道上,但格式错误,这就是我实现我想要的方式

    echo '<a href="pageone.php"><img src="'.get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_icon', get_template_directory_uri().'/images/features-box-icon-one.png' ).'" alt="'.get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_title' ).'" title="'.get_theme_mod( 'lawyeria_lite_frontpage_firstlybox_title' ).'" ;/></a>';
    

    【讨论】:

      猜你喜欢
      • 2014-04-21
      • 2014-06-26
      • 1970-01-01
      • 2010-09-28
      • 2012-07-02
      • 1970-01-01
      • 1970-01-01
      • 2018-01-02
      • 1970-01-01
      相关资源
      最近更新 更多