java多线程    Java入门    vsftp    ftp    linux配置    centos    FRP教程    HBase    Html5缓存    webp    zabbix    分布式    neo4j图数据库    

wordpress自定义php页面

1.找到自己的模板名字。后台,外观。即可看见当前主题名字Twenty Ten 1.3

2.服务器上/wp-content/themes/模板名字。我的为 /wp-content/themes/twentyten

3.复制首页index.php 一个改名为links.php(你改成你自己想要的名字。)

源码如下

<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
 
get_header(); ?>
 
		<div id="container">
			<div id="content" role="main">
 
			<?php
			/* Run the loop to output the posts.
			 * If you want to overload this in a child theme then include a file
			 * called loop-index.php and that will be used instead.
			 */
			 get_template_part( 'loop', 'index' );
			?>
			</div><!-- #content -->
		</div><!-- #container -->
 
<?php get_sidebar(); ?>
 
<?php get_footer(); ?>

源码改成

<?php
/*
Template Name: links
*/
 
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Twenty_Ten
 * @since Twenty Ten 1.0
 */
 
get_header(); ?>
 
<base target="_blank"/>
 
 
 
<?php get_links_list(); ?>
<?php get_footer(); ?>

开头这句话为
/*
Template Name: links
*/
表示这个文件是作为一个模板文件的。有了这句话,后台新建页面,选择模板的时候就会出现了。

<?php get_links_list(); ?>

表示调用所有链接。当然,这里你可以改成任何你想执行的php语句,或者html

去后台新建一个页面。看好了。是页面,不是文章。

新建的时候,出现了模板 links

我的这个页面叫"我在看的博客"。
效果 http://java-er.com/blog/my-reader/


This entry was posted in PHP and tagged . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/wordpress-php-page/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

*