douzhizao0270 2013-10-29 09:26
浏览 20

在wordpress中动态调用另一页面中的页面内容

I am trying to do something very characteristic and i am not that kinda good with PHP.

I am making some site for soccer team. And i want to have one main page called RESULTS. I will have for example 10 rounds(every round have separate page) in full season. I already make fixtures and everything depending on date.

My problem is how to call specific page, for example today is 29.10.2013 and my 3rd round has just over and i fill out all my result on my "3rd round page", and i want that this content be shown on page "RESULTS" also.

Than next week 04.11.2013 its coming my 4th round and i will also fill out everything on my "4th round page", but i just want now that all this be on "RESULTS" page because this is active round now not 3rd round.

I am guessing that i need to make template for my "RESULTS" page but i just need code, function how to call specific ID page depending on date. (29.10.2013 call page id 54; 04.11.2013 call page id 55). I hope i explained well and hope someone is good in this. Thanks in advance!

  • 写回答

3条回答 默认 最新

  • douyou2368 2013-10-29 16:49
    关注

    If you want to get the data of a specific page you can use "get_posts"

    http://codex.wordpress.org/Template_Tags/get_posts

    Inside your page template add something like this

    <ul>
    <?php
    $args = array( 'posts_per_page' => -1,
                   'post_type' => 'page', 
                   'include'=> $THE_PAGE_ID 
            );
    
    $myposts = get_posts( $args );
    foreach ( $myposts as $post ) : 
        setup_postdata( $post ); 
    ?>
        <li>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </li>
    <?php 
    endforeach; 
    wp_reset_postdata();
    ?>
    
    </ul>
    

    Or use "get_post":

    http://codex.wordpress.org/Function_Reference/get_post

    <?php 
    $thepost = get_post($THE_PAGE_ID, ARRAY_A);
    $title = $thepost['post_title'];
    echo $title;
    ?>
    

    Hope that's what you where after.

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分