使用我的索引页面作为WordPress中的不同页面。

huangapple go评论55阅读模式
英文:

Use my index page as a different page in WordPress

问题

我理解您的问题是如何将现有的 index.php 页面更名为 architects.php 并创建一个新的 index.php 页面,其中包含四个按钮,其中一个按钮将访问新的 architects.php 页面,同时保持 architects.php 的设计和动画效果。

要实现这个目标,您可以按照以下步骤操作:

  1. index.php 重命名为 architects.php
  2. 创建一个新的 index.php 文件,其中包含您想要的四个按钮作为锚点。
  3. 在新的 index.php 文件中,使用 HTML 和链接标签 (<a>) 创建这些按钮,并将其中一个按钮的链接指向 architects.php,其他按钮链接到其他页面。
  4. 确保您在 architects.php 中保留所需的动画效果和设计元素。

这样,您就可以实现您的目标,将 architects.php 作为一个独立的页面,并从新的 index.php 页面中链接到它。

英文:

I understand there's been a number of similar questions about this subject in the past years therefore I will try my best to be as descriptive as possible so my query can be understood from the get go. I am working on my WordPress site via my local machine, rolling on XAMPP and using Visual Studio Code as my code editor. I have my index.php set as my home page, this is the beginning of the code for such page:

&lt;?php get_header(); ?&gt;

&lt;?php if (!post_password_required($post)) { ?&gt;

	&lt;?php
	//get theme option
	$options = get_option(&#39;sample_theme_options&#39;);
	//echo &quot;wow&quot; . $options[&#39;sometext&#39;];
	?&gt;

	&lt;script&gt;
		var bgvidsrc = &quot;&lt;?php echo $options[&#39;bgv1&#39;]; ?&gt;&quot;;
		var bgvidsrc2 = &quot;&lt;?php echo $options[&#39;bgv2&#39;]; ?&gt;&quot;;
		var bgvidsrc3 = &quot;&lt;?php echo $options[&#39;bgv3&#39;]; ?&gt;&quot;;
		var bgvidsrc4 = &quot;&lt;?php echo $options[&#39;bgv4&#39;]; ?&gt;&quot;;
		var bgvidsrc5 = &quot;&lt;?php echo $options[&#39;bgv5&#39;]; ?&gt;&quot;;
		var bgvidsrc6 = &quot;&lt;?php echo $options[&#39;bgv6&#39;]; ?&gt;&quot;;
	&lt;/script&gt;

	&lt;?php $path = get_template_directory_uri() . &quot;/&quot;; ?&gt;

	&lt;!-- &lt;body onload=&quot;init()&quot;&gt; --&gt;

	&lt;body class=&quot;loading&quot;&gt;



		&lt;div id=&quot;pt-main&quot; class=&quot;pt-perspective&quot;&gt;

My aim is to use this page as a different page which I want to rename as architects.php and access it via a new index page I am going to create, which will contain 4 buttons as anchors, and one of those will take the visitor to the new architects.php (the other 3 buttons will be for other 3 categories as pages which I will spin up too).
I need to maintain the design for the new architects.php as it contains animations I want to display, just not as the index page but as its unique page (architects.php)
How can I do this?

答案1

得分: 1

文件名architects.php可以使用,但为了清晰起见,您可能想要在文件名前加上template-前缀。关键是要向文件添加模板标头:

/**
 * 模板名称:建筑师
 */

添加此标头将在“添加新页面”屏幕上的模板元框中的下拉菜单中添加“建筑师”。

官方文档:
https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use

英文:

The filename architects.php will be fine, though you may want to prefix the filename with template- for clarity. The key is to add a template header to the file:

/**
 * Template name: Architects
 */

Adding that header will add "Architects" to the dropdown in the Template meta box on the "Add New Page" screen.

Official doc:
https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-custom-page-templates-for-global-use

huangapple
  • 本文由 发表于 2023年6月1日 07:07:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76377787.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定