Wordpress: include content of one page in another

后端 未结 8 1312
挽巷
挽巷 2020-12-23 23:18

How do I include the page content of one or more page in another page?

ex. I have pageA, pageB and pa

8条回答
  •  自闭症患者
    2020-12-23 23:41

    Hi @dany:

    There is not a show_post() function per se in WordPress core but it is extremely easy to write:

    function show_post($path) {
      $post = get_page_by_path($path);
      $content = apply_filters('the_content', $post->post_content);
      echo $content;
    }
    

    Note that this would be called with the page's path, i.e.:

    
     Widget" page. ?>
    

    Of course I probably wouldn't name a function as generically as show_post() in case WordPress core adds a same-named function in the future. Your choice though.

    Also, and no slight meant to @kevtrout because I know he is very good, consider posting your WordPress questions on StackOverflow's sister site WordPress Answers in the future. There's a much higher percentage of WordPress enthusiasts answering questions over there.

    Hope this helps.

    -Mike

提交回复
热议问题