Hi i am new bee in wordpress customization, here is the slider code, i want to insert this code in to header and show only on home page please healp me
<?php
$slider_option = get_theme_mod('wp_store_homepage_setting_slider_option',0);
if ($slider_option == '1'):
do_action('wp_store_slider_section'); // Slider section- this function is in wp-store-function.php
endif;
?>
It would be much more simpler to just create ( if you dont have one ) a "HOME" page template, which is a fairly simple PHP page with a specific HEADING, so that you can choose that template when CREATING/EDITING pages.
Then in that code you add the part where you want your slider to show, and you can easily bypass these "is_home" or "is_frontpage" clauses.
Example :
<?php
/*
Template Name: NAME-OF-TEMPLATE
Author: NAME OF AUTHOR
Web Site: author url
Contact: author email
*/
get_header(); ?>
<!-- Get nav bar -->
<?php get_template_part( 'navigation', 'default' ); ?>
<!-- Start of page content -->
<div id="primary" class="site-content">
<div id="content" role="main">
<article id="post-0" class="post">
<header class="entry-header">
<!-- Page Title/head if needed -->
<!-- <h1 class="entry-title"><?php echo get_the_title(); ?></h1> -->
<!-- Your Code snippet -->
<?php
$slider_option = get_theme_mod('wp_store_homepage_setting_slider_option',0);
if ($slider_option == '1'):
do_action('wp_store_slider_section'); // Slider section- this function is in wp-store-function.php
endif;
?>
</header>
<!-- Main content -->
<div class="entry-content">
<!-- Rest of your content and page structure -->
</div><!-- .entry-content -->
</article><!-- #post-0 -->
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Please refer to this simple tutorial to help you familiarize your self : https://www.cloudways.com/blog/creating-custom-page-template-in-wordpress/
And WP referenses:
https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-page-templates-for-specific-post-types
// Use following code, is_front_page() returns true when viewing the Site Front Page.
<?php if(is_front_page()) {
$slider_option = get_theme_mod('wp_store_homepage_setting_slider_option',0);
if ($slider_option == '1'):
do_action('wp_store_slider_section'); // Slider section- this function is in wp-store-function.php
endif;
} ?>
You can try is_home() or is_front_page() which will determine if it is home page
if ( is_home() || is_front_page() ) {
$slider_option = get_theme_mod('wp_store_homepage_setting_slider_option',0);
if ($slider_option == '1'):
do_action('wp_store_slider_section'); // Slider section- this function is in wp-store-function.php
endif;
} else {
// Display what you want if not home
}
Look here for reference: is_home
Look here for reference: is_front_page
Related
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(); ?>
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.
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.
How can i create a page in a directory like public_html/test1 that has a single blank page with the header/sidebar/footer of my actual template.
I can only see the header, no sidebar , no content ( by content i mean "Hello." ).
I'm using twenty fourteen template.
This is the php code i am using:
<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/
require (dirname(dirname( __FILE__ )).'/wp-load.php');
get_header();
get_sidebar();
?>
Hello.
Note: if i delete the the_content(); get_footer(); , then the header ONLY appears but without format.
Any help deeply appreciated
The content isn't appearing because there's no loop inside your template. Please add this code inside your template and move your template file to the 'page-templates' folder inside the twentyfourteen theme.
<?php
/*
* Template Name: My own page!
* Description: I made a page!
*/
get_header(); ?>
<div id="main-content" class="main-content">
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
// Start the Loop.
while ( have_posts() ) : the_post();
// Include the page content template.
get_template_part( 'content', 'page' );
endwhile;
?>
</div><!-- #content -->
</div><!-- #primary -->
</div><!-- #main-content -->
<?php
get_sidebar();
get_footer();
p.s. you can remove the div's if you'd like to.
I am developing a very simple wordpress project. One of the page will have thumbnails of my projects and some texts and when I will click on the thumbnails it will land me to the page corresponding to the project. I created a template where i am trying to include another template which will just hold the thumbnails. I want to be able to update the thumbnails and text from two different pages from the wordpress dashboard. This is what I have so far...the concept is kinda goofy...let me know if i explained it correctly
lets say this is the rendering template
<?php
/*
Template Name: projects
* This template displays project thumbnails and introductory copy as a rendering template
*/
$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
get_header();?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<? /*php comments_template( '', true ); */?>
<?php endwhile; // end of the loop. ?>
<?php get_template_part( 'projectThumb', 'true' ); ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
and this is the thumbnail template.
<?php
/*
Template Name: projectThumb
* This template displays project thumbnails at the project page
*/
$options = twentyeleven_get_theme_options();
$current_layout = $options['theme_layout'];
get_header();?>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>