Wordpress不会让我在一个锚标记中包含一个div

时间:2017-01-13 11:53:08

标签: php html wordpress-theming custom-wordpress-pages

我在页面模板中,我正在尝试将整个div包装在标签中。我希望整个div元素可以被点击,而不仅仅是两个标题标记元素。标签被拆开并过早切割。嵌套问题?我不确定 - 尝试过很多不同的事情。这是代码...请参阅第<a href="<?php echo esc_url($education['lightbox']);?>">行是我试图包含的锚标记

    <section id="<?php echo esc_attr($menu_id);?>" class="section section-education">
                <div class="animate-up">
                    <?php if($title):?>
                        <h2 class="section-title"><?php echo esc_html($title);?></h2>
                    <?php endif;?>
                    <?php if($education_fields):?>
                    <div class="timeline">
                        <div class="timeline-bar"></div>
                        <div class="timeline-inner clearfix myBox">
                            <?php                               
                            $i=0;foreach ($education_fields as $education):
                                    if ($i % 2 == 0):
                                        $class = 'timeline-box-left';
                                        $class_inner = 'animate-right';
                                    else:
                                        $class = 'timeline-box-right';
                                        $class_inner = 'animate-left';                                      
                                    endif;
                            ?> 

                              <a href="<?php echo esc_url($education['lightbox']);?>">
                                <div class="timeline-box timeline-box-compact <?php echo esc_attr($class); ?>">
                                    <span class="dot"></span>

                                    <div class="timeline-box-inner <?php echo esc_attr($class_inner); ?>">
                                        <?php if($education['years']):?>
                                            <span class="arrow"></span>
                                            <div class="date"><?php echo esc_html($education['years']);?></div>
                                        <?php
                                        endif;
                                        if($education['education_name']):
                                            ?>
                                            <h3><?php echo esc_html($education['education_name']);?></h3>
                                        <?php
                                        endif;
                                        if($education['education_place']):
                                            ?>
                                            <h4>
                                            <?php if($education['education_place_link']):?>
                                                <a href="<?php echo esc_url($education['education_place_link']);?>">
                                            <?php endif;?>
                                            <?php echo esc_html($education['education_place']);?>
                                            <?php if($education['education_place_link']):?>
                                                </a>


                                            <?php endif;?>
                                            </h4>
                                        <?php endif;?>

                                    </div>
                                </div>
                                </a>
                            <?php $i++; endforeach; ?>
                        </div>
                    </div>
                    <?php endif;?>
                    <?php if($custom_editor):?>
                        <div class="section-txt-btn"><?php echo $custom_editor;?></div>
                    <?php endif;?>
                </div>
            </section>

这就是返回的内容:

    <div class="timeline-box timeline-box-compact timeline-box-left" style=""><a href="http://johnhoich.com/wp-content/uploads/2015/11/logo-compass-1.png" data-featherlight="image">
                                    <span class="dot"></span>

                                    </a><div class="timeline-box-inner animate-right animated"><a href="http://johnhoich.com/wp-content/uploads/2015/11/logo-compass-1.png" data-featherlight="image">
                                                                                        <span class="arrow"></span>
                        <div class="date">1974 - 1976</div>                                                                                 <h3>High School</h3>
                                                                                        </a><h4><a href="http://johnhoich.com/wp-content/uploads/2015/11/logo-compass-1.png" data-featherlight="image"></a>

Westside
                                                          

2 个答案:

答案 0 :(得分:0)

你有这个链接...

applicationId

...在您使用所引用的<a href="<?php echo esc_url($education['education_place_link']);?>"> 标记包装的DIV内部,但链接中的链接是不可能的,它肯定会破坏HTML ...

答案 1 :(得分:0)

想出来:

<强>解决方案: 我将<a>标记放在div / section的末尾并添加了一些css:使其成为绝对值,top,bottom,right,left =为0,相应地调整宽度和高度以覆盖整个内容区域随着提高z指数。这允许链接覆盖,而不是包裹div。