drh78568 2016-10-09 16:52
浏览 22

PHP代码没有显示在页面上

So I have a php page in wordpress and when I add a part of the code it doesn't work. So to explain a bit more. I have a php template and most of it works, but when I add some additional code at the bottom that doesn't show up.

            <?php get_header(); ?>
            <div class="main_color container_wrap_first container_wrap">
                <menu id="nav">
                <ul><?php   
                    $category_id = 2;
                                while( $category_id < 7 ) { ?> 
                            <li>
                            <a href="<?php echo get_category_link( $category_id ); ?>">
                            <?php
                            $cat_id = $category_id;
                            echo get_cat_name( $cat_id );
                            $category_id++;
                            ?>
                            </a>                
                            </li>
                        <?php } ?>  

                </ul>
        </menu>

         <?php
                    $args = array(
                        'post_type' => 'projekti',
                        'posts_per_page' => -1,
                        'category'      => '4',
                    );
                    $posts = get_posts($args);

                    if( $posts ): 
                    $i = 1; ?>
                                <div class="custom-posts-grid">
                    <?php foreach($posts as $post): setup_postdata( $post ); ?>
                        <?php if( have_rows('logotipi') ): ?>
                            <?php while( have_rows('logotipi') ): the_row();
                                // vars
                                $image = get_sub_field('thumbnail_for_logotipi');
                                $content = get_sub_field('project_name');
                                $link = get_sub_field('url_logotipi');
                                $count = count($posts);

                                ?>      
                                <div class="post-grid-logotipi">
                                    <a href="<?php echo $link; ?>">
                                    <div class="post-title-hover"><?php echo $content ?></div>
                                    <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt'] ?>" class="image-overlay-post" />
                                    </a>
                                </div>
                                <?php 
                                $i++; 
                                if( $i == 6 ): 
                                    $i++;
                                ?>
                                    <div class="sodelujmo-post-grid"><div class="sodelujmo-post"><p class="sodelujmo-text">Vam je všeč,<br>kar vidite?<br>...<p><div class="button-bg"><a class="sodelujmo-link" href="../u3nek/sodelujmo/">Sodelujmo</a>
                                    </div></div></div>
                                <?php 
                                endif; ?>
                            <?php endwhile; ?>
                        <?php endif; ?>                         
                    <?php endforeach; ?>
                    <?php wp_reset_postdata(); ?>
                    <?php endif; ?>
                    <!-- after this nothing I add can be shown -->
            </div>
            </div>

I have no idea what is wrong. So if anyone encountered anything similar before do let me know.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 关于大棚监测的pcb板设计
    • ¥15 stm32开发clion时遇到的编译问题
    • ¥15 lna设计 源简并电感型共源放大器
    • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)