如何将页面(及其模板)合并为一页? [英] How do I combine pages (and their templates) into one page?

查看:156
本文介绍了如何将页面(及其模板)合并为一页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望CMS具有不同的页面(例如职业,工作,团队),每个页面都有自己的模板,然后将它们组合成一个大的可滚动页面(例如 Our Company)那会有一个模板。我该怎么做?

I want the CMS to have the different pages (e.g. "Careers", "Jobs", "Team") with each having its own template, but then to combine them into one big scrollable page (e.g. "Our Company") that would have a template. How would I do this?

我知道有使用作为函数 get_page ,但已弃用(并替换为 get_post ,这不是同一回事),但是不会检索页面的模板。

I know there used to be a function get_page but that's been deprecated (and replaced with get_post which is not the same thing), but that doesn't retrieve the page's template.


  1. 我想要页面和模板,这样我就可以将它们都输出到主页中。

  1. I want both the page and the template so I can output both into the main page.

我也希望这样做,因此,如果有人在导航菜单中单击以转到工作或团队,则会将他们带到我们的公司页面,但带有查询字符串,以便我可以将它们滚动到页面的该部分

I also want it so if someone clicks in the navigation menu to go to "Jobs" or "Team", it will take them to that "Our Company" page, but with a querystring so I can scroll them to that part of the page

这可能吗?

推荐答案

首先为主页模板选择默认模板,然后在其中编写全局元素。在此模板中,使用get_template部分包含页面

First for main page template choose default template and write you global elements there. And in this template use get_template part to include pages

<!--custom query for pages-->
<?php
$args= array('post_type'=>'page');
$query= new WP_Query($args);  
$query->while(have_posts()):query->the_post(); 
 $temp_name= get_page_template_slug( $post->ID );       
 $temp_name_exp =explode('.',$temp_name);
 get_template_part($temp_name_exp[0]); 

endwhile;
endif;
?>

以及在职业,博客等页面中

and in career, blog etc pages

<?php
/*
Template name: Career or blog or something else
*/ 
?>
<?php the_tiele();
      the_content();
 ?>

for
我也希望这样做,如果有人单击导航菜单中的 Jobs或 Team,它将带他们到 Our Company页面,但是带有查询字符串,因此我可以将它们滚动到页面的该部分
将每个页面包装器分配给页面slug示例< section class =<?php echo $ post-> post_name;?>> 并编写一个函数将您的视图页面链接重定向到 http://您的网站网址/#page-slug

for "I also want it so if someone clicks in the navigation menu to go to "Jobs" or "Team", it will take them to that "Our Company" page, but with a querystring so I can scroll them to that part of the page" assign each pages wrapper to page slug example <section class="<?php echo $post->post_name; ?>"> and write a function to redirect your view page link to http://yoursiteurl/#page-slug

这篇关于如何将页面(及其模板)合并为一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆