简体   繁体   中英

Modifying Wordpress PHP dynamic content

My page is bewitcheryinc.com I am trying to re-arrange my home page. I need to switch the promotional area (section with 3 rectangles) with the text below it. I need to have the text displayed first and then the promotional area (section with 3 rectangles). 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.

<?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:

.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. 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. 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. Thank you!

I think this would work:

In index.php move the

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

right before

get_template_part( 'pagination', 'none' );

in 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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