【问题标题】:How to create a duplicate home page in Wordpress (Genesis child theme)如何在 Wordpress 中创建重复的主页(创世纪子主题)
【发布时间】:2014-06-11 18:53:35
【问题描述】:

我想创建我的主页的副本,以便我可以使用 Google Analytics 进行拆分测试。我通过将 front-page.php 复制并粘贴到新的 php 文件中来创建自定义页面模板。新模板出现了,但是当我使用新模板创建页面时,页面的博客部分丢失了。

这是我的主页:http://teamrcia.com

这是副本:http://www.teamrcia.com/homepage2/

副本的 php 代码如下。谁能帮我看看我错过了什么?非常感谢。

尼克·瓦格纳

<?php

/*
 * Template Name: Home Page 2
 */
/**
 * This file adds the Home Page to the Streamline Pro Theme.
 *
 * @author StudioPress
 * @package Streamline Pro
 * @subpackage Customizations
 */

add_action( 'genesis_meta', 'streamline_home_genesis_meta' );
/**
 * Add widget support for homepage. If no widgets active, display the default loop.
 *
 */
function streamline_home_genesis_meta() {

    if ( is_active_sidebar( 'home-featured-1' ) || is_active_sidebar( 'home-featured-2' ) || is_active_sidebar( 'home-featured-3' ) ) {

    //* Force content-sidebar layout setting
    add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );

    // Add streamline-pro-home body class
    add_filter( 'body_class', 'streamline_body_class' );

    // Add homepage widgets
    add_action( 'genesis_before_content_sidebar_wrap', 'streamline_homepage_widgets' );

    }
}

function streamline_body_class( $classes ) {

    $classes[] = 'streamline-pro-home';
    return $classes;

}

function streamline_homepage_widgets() {

    if ( is_active_sidebar( 'home-featured-1' ) || is_active_sidebar( 'home-featured-2' ) || is_active_sidebar( 'home-featured-3' ) ) {

    echo '<div class="home-featured">';

    genesis_widget_area( 'home-featured-1', array(
        'before' => '<div class="home-featured-1 widget-area">',
        'after'  => '</div>',
    ) );

    genesis_widget_area( 'home-featured-2', array(
        'before' => '<div class="home-featured-2 widget-area">',
        'after'  => '</div>',
    ) );

    genesis_widget_area( 'home-featured-3', array(
        'before' => '<div class="home-featured-3 widget-area">',
        'after'  => '</div>',
    ) );

    echo '</div><!-- end #home-featured -->';   

    }

}

genesis();  

【问题讨论】:

    标签: wordpress custom-pages genesis


    【解决方案1】:
    1. 在您的 Wordpress 仪表板中,转到外观 > 编辑器并选择您的主页正在使用的模板(很可能是 home.php)
    2. 将内容复制到一个文本文件中并为其命名(例如 new_template.php)并在代码顶部添加一个模板名称。
    3. 使用 FTP 将此 PHP 文件上传到 wp-content/themes/your-chosen-theme/ 文件夹。
    4. 返回仪表板,转至页面 > 新增。在右侧面板上,选择您添加的新模板。
    5. 发布和查看页面。它应该类似于您的主页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-16
      • 1970-01-01
      • 2014-08-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多