简体   繁体   English

修改Wordpress PHP动态内容

[英]Modifying Wordpress PHP dynamic content

My page is bewitcheryinc.com I am trying to re-arrange my home page. 我的页面是bewitcheryinc.com,我正在尝试重新排列主页。 I need to switch the promotional area (section with 3 rectangles) with the text below it. 我需要用下面的文字切换促销区域(带有3个矩形的部分)。 I need to have the text displayed first and then the promotional area (section with 3 rectangles). 我需要先显示文本,然后显示促销区域(带有3个矩形的部分)。 I have contacted theme support, and they told me that the content is dynamic and the only solution to try is to replace header.php with the following code. 我已经联系了主题支持,他们告诉我内容是动态的,唯一尝试的解决方案是用以下代码替换header.php。

<?php
/**
 * Displays the header content
 *
 * @package Theme Freesia
 * @subpackage Edge
 * @since Edge 1.0
 */
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<?php
$edge_settings = edge_get_theme_options(); ?>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<div id="page" class="hfeed site">
<!-- Masthead ============================================= -->
<header id="masthead" class="site-header">
        <?php if ( function_exists( 'the_custom_header_markup' ) ) {
            if ( is_header_video_active() && ( has_header_video() || is_customize_preview() ) ) {
                echo '<div class="custom-header">
                    <div class="custom-header-media">';
                the_custom_header_markup();
                echo '</div>
                </div>';
            }else{ 
                if ( has_header_image() ) {?>
                    <a href="<?php echo esc_url(home_url('/'));?>"><img src="<?php header_image(); ?>" class="header-image" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" /> </a>
                <?php }
            }
        } else { ?>
        <a href="<?php echo esc_url(home_url('/'));?>"><img src="<?php header_image(); ?>" class="header-image" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="<?php echo esc_attr(get_bloginfo('name', 'display'));?>" /> </a>
        <?php } ?>
        <div class="top-header">
            <div class="container clearfix">
                <?php
                if( is_active_sidebar( 'edge_header_info' )) {
                    dynamic_sidebar( 'edge_header_info' );
                }
                if($edge_settings['edge_top_social_icons'] == 0):
                    echo '<div class="header-social-block">';
                        do_action('social_links');
                    echo '</div>'.'<!-- end .header-social-block -->';
                endif;
                 do_action('edge_site_branding'); ?>
            </div> <!-- end .container -->
        </div> <!-- end .top-header -->
        <!-- Main Header============================================= -->
                <div id="sticky_header">
                    <div class="container clearfix">
                        <h3 class="nav-site-title">
                            <a href="<?php echo esc_url(home_url('/'));?>" title="<?php echo esc_attr(get_bloginfo('name', 'display'));?>"><?php bloginfo('name');?></a>
                        </h3>
                    <!-- end .nav-site-title -->
                        <!-- Main Nav ============================================= -->
                        <?php
                            if (has_nav_menu('primary')) { ?>
                        <?php $args = array(
                            'theme_location' => 'primary',
                            'container'      => '',
                            'items_wrap'     => '<ul id="primary-menu" class="menu nav-menu">%3$s</ul>',
                            ); ?>
                        <nav id="site-navigation" class="main-navigation clearfix">
                            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                <span class="line-one"></span>
                                <span class="line-two"></span>
                                <span class="line-three"></span>
                            </button>
                            <!-- end .menu-toggle -->
                            <?php wp_nav_menu($args);//extract the content from apperance-> nav menu ?>
                        </nav> <!-- end #site-navigation -->
                        <?php } else {// extract the content from page menu only ?>
                        <nav id="site-navigation" class="main-navigation clearfix">
                            <button class="menu-toggle" aria-controls="primary-menu" aria-expanded="false">
                                <span class="line-one"></span>
                                <span class="line-two"></span>
                                <span class="line-three"></span>
                            </button>
                        <!-- end .menu-toggle -->
                            <?php   wp_page_menu(array('menu_class' => 'menu', 'items_wrap'     => '<ul id="primary-menu" class="menu nav-menu">%3$s</ul>')); ?>
                        </nav> <!-- end #site-navigation -->
                        <?php }
                        $search_form = $edge_settings['edge_search_custom_header'];
                        if (1 != $search_form) { ?>
                            <div id="search-toggle" class="header-search"></div>
                            <div id="search-box" class="clearfix">
                                <?php get_search_form();?>
                            </div>  <!-- end #search-box -->
                        <?php } 

            echo '</div> <!-- end .container -->
            </div> <!-- end #sticky_header -->';
        $enable_slider = $edge_settings['edge_enable_slider'];
        edge_slider_value();
        if ($enable_slider=='frontpage'|| $enable_slider=='enitresite'){
            if(is_front_page() && ($enable_slider=='frontpage') ) {
                if($edge_settings['edge_slider_type'] == 'default_slider') {
                        edge_page_sliders();
                }else{
                    if(class_exists('Edge_Plus_Features')):
                        edge_image_sliders();
                    endif;
                }
            }
            if($enable_slider=='enitresite'){
                if($edge_settings['edge_slider_type'] == 'default_slider') {
                        edge_page_sliders();
                }else{
                    if(class_exists('Edge_Plus_Features')):
                        edge_image_sliders();
                    endif;
                }
            }
        } ?>
</header> <!-- end #masthead -->
<!-- Main Page Start ============================================= -->
<div id="content">
<div class="container clearfix">
<?php 
if(is_front_page()){
    if( have_posts() ) {
        while( have_posts() ) {
        the_post();
        get_template_part( 'content', get_post_format() );
        }
    } else { ?>
    <h2 class="entry-title"> <?php esc_html_e( 'No Posts Found.', 'edge' ); ?> </h2>
    <?php }

    do_action('edge_display_frontpage_features');
}
if(!is_home()){?>
    <div class="page-header">
        <h1 class="page-title"><?php echo edge_header_title(); ?></h1>
        <!-- .page-title -->
        <?php edge_breadcrumb(); ?>
        <!-- .breadcrumb -->
    </div>
    <!-- .page-header -->
<?php }

After I replace headr.php, I have to add the following css: 替换headr.php后,必须添加以下CSS:

.home .entry-header, .home .entry-meta, section#post-417, .home .entry-footer {
display:none;
}

When I follow these instructions, the home page displays my original page text as a blog post with "read more" tags, along with the meta tags. 当我按照这些说明进行操作时,主页将我的原始页面文本显示为博客文章,其中包含“更多”标签以及meta标签。 The read more link links back to the home page. 阅读更多链接链接回到首页。 I simply want the front page to display my page title, some text, and then the promotional picture boxes. 我只希望首页显示我的页面标题,一些文本,然后显示促销图片框。

If it is helpful, I beleive that when promotional area is turned on, the theme uses front-page-feature.php template instead of an index page. 如果有帮助,我相信打开促销区域后,主题将使用front-page-feature.php模板而不是索引页。 It is bellow. 吼叫。

<?php
function edge_frontpage_features(){
    $edge_settings = edge_get_theme_options();
    if($edge_settings['edge_disable_features'] != 1){
        $edge_features = '';
        $edge_total_page_no = 0; 
        $edge_list_page = array();
        for( $i = 1; $i <= $edge_settings['edge_total_features']; $i++ ){
            if( isset ( $edge_settings['edge_frontpage_features_' . $i] ) && $edge_settings['edge_frontpage_features_' . $i] > 0 ){
                $edge_total_page_no++;

                $edge_list_page =   array_merge( $edge_list_page, array( $edge_settings['edge_frontpage_features_' . $i] ) );
            }

        }
        if ( !empty( $edge_list_page ) && $edge_total_page_no > 0 ) {
            echo '<!-- Promotional Area ============================================= -->';
                $edge_features  .= '<div class="promonational-area">';
                                $get_featured_posts         = new WP_Query(array(
                                'posts_per_page'        => $edge_settings['edge_total_features'],
                                'post_type'             => array('page'),
                                'post__in'              => $edge_list_page,
                                'orderby'               => 'post__in',
                            ));
                    $edge_features .= '<div class="column clearfix">';
                $j = 1;
                while ($get_featured_posts->have_posts()):$get_featured_posts->the_post();
                $attachment_id = get_post_thumbnail_id();
                $image_attributes = wp_get_attachment_image_src($attachment_id,'pixgraphy_promotional_image');
                            $excerpt                     = get_the_excerpt();
                    $edge_features .= '<div class="three-column">';
                    if ($image_attributes) {
                        $edge_features  .= '<div class="promonational-img" title="'.the_title('', '', false).'"' .' style="background-image:url(' ."'" .esc_url($image_attributes[0])."'" .')"> <a class="promonational-link" href="'.get_the_permalink().'"></a>   ';
                        $edge_features .= '<div class="promonational-overlay">
                                <h4>'.get_the_title().'</h4></div></div>';
                    }
                    $edge_features  .='</div><!-- end .three-column -->';
                    $j++;
                    endwhile;
                    $edge_features  .='</div><!-- .end column-->';
                    $edge_features  .='</div><!-- end .promonational-area -->';
                }
        echo $edge_features;
    }
        wp_reset_postdata();
}
add_action('edge_display_frontpage_features','edge_frontpage_features');

Can anyone help? 有人可以帮忙吗? I am not proficient obviously in PHP/WordPress at all. 我显然不精通PHP / WordPress。 Thank you! 谢谢!

I think this would work: 我认为这会起作用:

In index.php move the 在index.php中移动

if(is_front_page()){ do_action('edge_display_frontpage_features'); }

right before 就在之前

get_template_part( 'pagination', 'none' );

in header.php. 在header.php中。

This would put the front-page feature after the 'main' content in the primary section of the post. 这会将首页功能放在帖子主要部分的“主要”内容之后。 Now you need to figure out how to put the right post content for the text. 现在,您需要弄清楚如何为文本添加正确的帖子内容。 Currently it seems like it's not fetching the correct post type. 目前看来,它没有获取正确的帖子类型。 It's probably the sample post in the post post type. 这可能是帖子类型中的示例帖子。

But is the text supposed to be static or changes with your recently posted content? 但是该文本应该是静态的还是随您最近发布的内容而变化? If its supposed to static, you should go in Settings->Reading in the admin dashboard and set the front-page to a static page and then you can put in the text into that page content. 如果它应该是静态的,则应进入管理控制台中的“设置”->“读取” ,并将首页设置为静态页面 ,然后将文本放入该页面内容中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM