Content inside page template is misplaced - php

I have a template in my Genesis theme child that is assigned to my homepage with a div that has an ID that I've styled in a separate CSS file.
That div contains a text, in the CSS sheet there's a background image to it.
I have a styled header through hooking it up through functions.
I have a footer aswell.
The problem is - the div that I mentioned is rendered below all these elements, as if it's not a part of the genesis structure.
There's header, footer, and below that the image with the text.
If I edit the page through the dashboard a new post is created that is positioned correctly.
How do I display the picture between the header and footer like it should be?
The code for the homepage template is:
<?php
/*
Template Name: Homepage Template
*/
genesis();
echo "<link rel='style' type='text/css' href='styles.css' />";
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
</header><!-- .entry-header -->
<div class="entry-content">
<div id="home_slider">
Electrical & Mechanical Engineering<br>In Nigera
</div>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php endwhile; // End the loop. ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>

The thing about Genesis content is that you have to use the Genesis hooks to add content to your page. There is a great visual guide for this here: http://genesistutorials.com/visual-hook-guide/
In your case, if you wanted to place your div just before the content area, you could do the following:
/**
* Template Name: Homepage Template
*/
add_action('genesis_before_content', 'add_extra_content_div');
function add_extra_content_div(){
?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
</header><!-- .entry-header -->
<div class="entry-content">
<div id="home_slider">
Electrical & Mechanical Engineering<br>In Nigera
</div>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php endwhile; // End the loop. ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
?>
}
genesis();
One other point is that in Genesis you do not need to put in get_header() and get_footer() so you should remove these from your template.
Also, make sure that genesis(); is the very last line in the template - this is very important.

Related

Blog Main Header Showing Recent Post Title Instead

My Wordpress blog works fine on the main page that shows all posts, however, when I click a category the most recent post's title becomes the main header and that post doesn't even show up in the blog post list of that category.
https://ibb.co/ebReRV
I spied on other people with the same theme as me and they have the same problem so I believe this is a problem with the original code. My theme's creator seems to have disappeared and hasn't responded to any of my messages.
archive.php
<section id="wp-main-content" class="clearfix main-page title-layout-standard">
<?php do_action( 'naturalfood_before_page_content' ); ?>
<div class="container">
<div class="main-page-content row">
<!-- Main content -->
<div class="content-page <?php echo esc_attr($main_content_config['class']); ?>">
<div id="wp-content" class="wp-content">
<?php get_template_part('templates/layout/archive') ?>
</div>
</div>
You Need to Create Archive Page
Give Archive Page name is "archive.php".
Archive Page Structure Like this:
<?php
/*
Template Name: Archives
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<h1 class="entry-title"><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
/* Custom Archives Functions Go Below this line */
/* Custom Archives Functions Go Above this line */
</div><!-- .entry-content -->
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

get_footer not showing for Wordpress site

For some reason my footer disappeared for my site http://juliannaspizza.com.
I checked the template file for the home page and get_footer is being called as shown below. Any idea why my footer is still not showing up?
<?php
/**
* Template Name: Full Width Page
*
* #package Fortune
*/
get_header();
get_template_part( 'parts/single', 'page-header' ); ?>
<div class="container full-width-page">
<div class="row">
<div id="primary" class="content-area col-lg-12">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) : the_post();
get_template_part( 'content', 'page' );
if ( comments_open() || get_comments_number() ) {
comments_template();
}
endwhile; ?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .row -->
</div><!-- .container -->
<?php
get_footer();
This is what my footer used to look like (https://certifagift.blog/):
Your widgets are gone. From the markup, it looks like your footer (which does appear) is expecting to have widgets, but those are not appearing. Go to Appearance -> Widgets in your dashboard and add your widgets back in, and you should be good.

Apply css to custom Wordpress template

I am trying to establish 2 x custom page templates for a site using Zerif Pro on Wordpress 4.7.3
I have created the template files but can't get the layout I want.
I am trying to get a full-width template where the content appears directly below the navbar.
Using inspect element I can edit the CSS to
.content-left-wrap {
padding-top: 0px;
}
And get the desired look, but I can't figure out what to change in my fullwidth.php file or where to put it.
Template Code Below:
<div class="clear"></div>
</header> <!-- / END HOME SECTION -->
<?php zerif_after_header_trigger(); ?>
<div id="content" class="site-content">
<div class="container">
<div class="content-left-wrap col-md-12">
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
while ( have_posts() ) :
the_post();
get_template_part( 'content', 'page-no-title' );
/* If comments are open or we have at least one comment,
load up the comment template */
if ( comments_open() || '0' != get_comments_number() ) :
comments_template();
endif;
endwhile;
?>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- .content-left-wrap -->
</div><!-- .container -->
<?php
get_footer();
?>
Edit fullwidth.php Add another class to this div like this
<div class="content-left-wrap wrap-new col-md-12">
and then add css to the template css file using the new class
.wrap-new
{
.content-left-wrap {
padding-top: 0px;
}
}

custom theme for wordpress new page

I created a custom theme for word-press. When i say 'add new' page and i put content into this page it only displays the footer and header but dosnt hook my content which is in the CMS on that page.
This is what i have : page.php
<?php get_header(); ?>
<div class="row">
<div class="col-sm-12">
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile; endif;
?>
</div> <!-- /.col -->
</div> <!-- /.row -->
<?php get_footer(); ?>
Its been a long day what am i doing wrong here. Any tips please?
Would also like to make like a parent page from this new page, but its only option with page attributes are 'default template'.
If you didn't have a template part please use the_content() instead of
get_template_part( 'content', get_post_format() );
My actual problem, resolved. So i used 'advanced custom field' plugin for my WordPress. The problem using this is that it still requires you to do some coding.
I added a new page.
For that page I had an header image and content. So for ACF(advanced custom field) that is equal to two field types "Image --> field type and Text-Area --> field type"
Field name is what i used to call the fields to my .php page template.
Field Name : Image = header-image
Field Name : (2)Text Area = header-image-text-top (and) header-image-text-author
(I needed to display my text on the image thats why my div is just based on header image.)
So I hooked my page template and then added the the hooks for the fields i want to display on this page template.
page-stay.php :
<?php
/*Template Name: Stay - Parent Page */
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php
// Start the loop.
while ( have_posts() ) : the_post(); ?>
<article id="post=<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- <header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header>(you can use this if you need your page header to display)-->
<div class="enry-content">
<?php
$image = get_field('header-image');
if( !empty($image) ): ?>
<div class="head-image">
<img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" />
<div class="head-text-box">
<div class="head-text-box-holder">
<p class="headtext-quote"><?php the_field('header-image-text-top'); ?></p>
<p class="headtext-author"><?php the_field('header-image-text-bottom'); ?></p>
</div>
</div>
</div>
<?php endif; ?>
</article>
<?php endwhile; ?>
</main><!-- .site-main -->
</div><!-- .content-area -->
<?php get_footer(); ?>

How to use shortcode in a template

Below you can see my home page template. I used to have this line in the content of my page, it loads the thumbnail and the video player with video. I now want to have this in a template but i dont know how to call it properly. You can see I am trying to call the video from my theme options panel.
Before
[KGVID poster="http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg" width="1005" height="565"]http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/sample.mp4[/KGVID]
After
[KGVID poster="http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg" width="1005" height="565"]http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/sample.mp4[/KGVID]
Any help would be much appreciated.
<?php /* Template Name: Home Page */ get_header(); ?>
<!-- section -->
<section role="main">
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
[KGVID poster="http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg" width="1005" height="565"]<?php echo $smof_data['home-page-video-url'];?>[/KGVID]
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
</section>
<!-- /section -->
<?php get_footer(); ?>
For using shortcode in templates do this
<?php echo do_shortcode("[KGVID poster='http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/thumbnail-home.jpg' width='1005"' height='565']http://www.muratgokmen.co.uk/wp-content/uploads/2013/09/sample.mp4[/KGVID]"); ?>

Categories