我正在使用wordpress主题。默认的主页是最新的帖子。在我的主题中,它是home.php,它是默认主页的内容。现在我想有一个静态的主页和博客页面。我创建了一个名为“主页”的新页面,并将其设置为主页。因此,之前的默认主页内容不会出现在我的新主页上。我的问题是如何将这些默认主页内容添加到这个新主页?我不想改变page.php模板,因为它会改变所有的页面。我想改变这个特定的“主页”页面,并将其设置为带有先前默认主页内容的主页。有人能帮帮我吗?
这是默认的主页代码
<?php get_header(); ?>
<?php if ( get_option('modest_quote') == 'on' ) { ?>
<div id="quote">
<p id="quote-1"><span class="tagline-quote">“</span><?php echo get_option('modest_quote_one'); ?><span class="tagline-quote">”</span></p>
<p id="quote-2"><?php echo get_option('modest_quote_two'); ?></p>
</div> <!-- end #quote -->
<?php } ?>
<?php if ( get_option('modest_featured') == 'on' ) get_template_part('includes/featured'); ?>
<?php if ( get_option('modest_blog_style') == 'false' ){ ?>
<div id="blurbs" class="clearfix">
<?php
$blurbs_number = get_option('modest_use_third_page') == 'on' ? 3 : 2;
if ( get_option('modest_use_third_page') == 'on' ) $blurbs_number = 3;
?>
<?php for ($i=1; $i <= $blurbs_number; $i++) { ?>
<?php query_posts('page_id=' . get_pageId(html_entity_decode(get_option('modest_home_page_'.$i)))); while (have_posts()) : the_post(); ?>
<?php
global $more; $more = 0;
?>
<div class="blurb<?php if ( $i == 3 ) echo ' last'; ?>">
<h3 class="title"><?php the_title(); ?></h3>
<?php the_content(''); ?>
</div> <!-- end .blurb -->
<?php endwhile; wp_reset_query(); ?>
<?php } ?>
<?php if ( $blurbs_number == 2 ) { ?>
<div class="blurb last">
<h3 class="title"><?php esc_html_e('Examples of Our Work','Modest'); ?></h3>
<?php query_posts("showposts=".get_option('modest_work_number')."&cat=".get_cat_ID(get_option('modest_work_cat')));
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php
$width = 56;
$height = 56;
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,'item-image',$titletext,$titletext,true,'Work');
$thumb = $thumbnail["thumb"];
$fancybox_title = get_post_meta($post->ID,'Customtitle',true) ? get_post_meta($post->ID,'Customtitle',true) : get_the_title(); ?>
<div class="thumb">
<a rel="gallery" title="<?php echo esc_attr($fancybox_title); ?>" href="<?php echo esc_attr($thumbnail['fullpath']); ?>" class="fancybox">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, 'item-image'); ?>
<span class="overlay"></span>
<span class="zoom-icon"></span>
</a>
</div> <!-- end .thumb -->
<?php
endwhile; endif;
wp_reset_query(); ?>
</div> <!-- end .blurb -->
<?php } ?>
</div> <!-- end #blurbs -->
<?php } else { ?>
<div id="left-area">
<?php get_template_part('includes/entry','home'); ?>
</div> <!-- end #left-area -->
<?php get_sidebar(); ?>
<?php } ?>发布于 2015-05-25 11:45:42
请试一下,它会给你答案的
请从管理面板将主页模板和标志模板放到该页面,并将下面的代码放在您创建的新模板页的顶部。
/*
Template Name: Home Page
The template for displaying Home
*/在管理面板中创建的wordpress页面中选择主页模板
发布于 2015-05-25 12:28:56
您可以为单独的主页设计创建主页模板。有关如何在WordPress中制作模板,请参考以下链接。
然后在你的主页编辑模式,在管理面板,请选择模板。
有帮助的功能,获取内容,特色形象和所有你可以使用的功能,如列出如下。
the_content();
get_the_post_thumbnail();
get_permalink();
get_excerpt()等,请在模板中保持相同的html,只需将php代码放在您想要的图像内容等。
发布于 2015-05-25 15:33:23
为此任务创建并使用前端-page.php模板文件!只需将code .php的代码转储到前端-page.php。
如果存在,则在站点的首页上使用front-page.php模板文件,无论‘设置>阅读->Front页面显示’设置为“静态页面”还是“您的最新帖子”,主题都需要考虑这两个选项,这样站点首页将显示静态页面或博客帖子索引。
看看这个官方的WordPress文档Page
https://stackoverflow.com/questions/30436403
复制相似问题