Hi i am trying to use two different sidebars for both pages and posts.
For that I have used the following condition to test if it is a page (if yes call "sidebar-15" otherwise call "blog").
<?php
if (is_page()){
dynamic_sidebar( 'sidebar-15' );
}
else {
get_sidebar( 'blog' );
}
?>
But, on pages it is still calling blog side bar. Is there something that I am doing wrong?
get_sidebar function
<?php get_sidebar( $name_of_sidebar_file ); ?>
for example:
files: sidebar-right.php and sidebar-left.php
calling:
get_sidebar('right');
get_sidebar('left');
Related
I am currently using
<?php if ( is_home() ) :
get_header( 'home' );
endif;
?>
To call 'header-home.php' on the homepage only.
I also want to call 'header-fullwidth.php' on our full width posts.
This is one of our full width posts: http://www.sickchirpse.com/photos-vatnajokull-glacier/
This is a normal post (it has a sidebar): http://www.sickchirpse.com/how-survive-european-squat-house-berlin/
What can I add to achieve this?
if(get_page_template() == 'your-full-width-template'):
get_header( 'full-width' );
endif;
You can alwasy check the current page template path with the get_page_template() function.
I'm a bit new to this, but I researched this topic a bit online and can't seem to figure out what I'm doing wrong. So basically, I created a duplicate footer to call for the homepage. We use a marketing automation tool called Pardot and we don't want to track visits to the homepage. So I created a file in the footer folder next to "footer-default.php" called "footer-nopardot.php" that omits the code.
In the home.php file, I edit the bottom with
<?php
get_footer('nopardot'); ?>
But it appears the homepage is still calling the default footer. Any advice on what to do or what I'm doing wrong?
Thanks!
just add this to your home template:
<?php
if ( is_home() ) :
get_footer( 'nopardot' );
else :
get_footer();
endif;
?>
you can use this loop just replace the home or 404 by your page name where you want to display your footer:
<?php
if ( is_home() ) :
get_footer( 'home' );
elseif ( is_404() ) :
get_footer( '404' );
else :
get_footer();
endif;
?>
and since you are just changing your home page footer u can just do this
<?php
if ( is_home() ) :
get_footer( 'yourName' );
else :
get_footer();
endif;
?>
Make sure of the file name to be footer-yourName.php
and then call it as follow:
get_footer( 'yourName' );
hope that helps :)
Is there any possible way to change the loop structure of the Genesis Framework so that the loop header appears within the same div as the entry content?
I have tried messing around with the loop.php file in the genesis template and I have also tried looking up different hooks, but I can't seem to find anything that helps.
Is there anyone that has accomplished this or would have an idea?
To customize the loop in Genesis, before you need to remove Genesis Loop:
remove_action( 'genesis_loop', 'genesis_do_loop' );
then you can add your custom loop
add_action( 'genesis_loop', 'my_custom_loop' );
Here is a basic example for 'standard-looking' loop working in Genesis:
function my_custom_loop() {
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Your Code Here
<?php endwhile; ?>
<?php endif; ?>
<?php
}
genesis();
?>
Please note that your function must end with 'genesis();' to work!
So the whole page code can be:
<?php
/*
* Your Custom Page
*/
?>
<?php
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'my_custom_loop');
function my_custom_loop() {
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
// Your Code
<?php endwhile; ?>
<?php endif; ?>
<?php
}
genesis();
?>
Hope it helps ;)
Here is simple approach.
You first remove the entry header stuff from the header.
e.g.
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
Once the header markup as well as entry title and entry info is removed from top.
You can add them back into your page in your desired position i.e. genesis_entry_content hook.
e.g.
add_action( 'genesis_entry_content', 'genesis_do_post_title' );
Hope this helps. Let me know if you face any issue.
Sorry forgot to add that you will need to add this custom code in your child theme's functions.php file if you want it to impact to whole site. And if you want this to happen on certain template, then in that template file in the child theme of Genesis.
I list all the most common Genesis hooks and filters used by me while developing a website without boring you with more contents.
https://icodefy.com/common-genesis-hooks-filters/
I'm trying to insert a widget into a shortcode that I'm storing in my footer.php file...
<?php
echo do_shortcode( '[accordion_full_width title="upcoming events" full_width="yes" background_color="#68676b"]' .
dynamic_sidebar( 'footer_contents' )
. '[/accordion_full_width]'); ?>
...and it renders out the widget first, followed by the shortcode.
If this is a problem with using the dynamic_sidebar function inside of the do_shortcode, I'd think it just wouldn't spit the widget out, but it does. In the wrong place.
Does anybody have anything?
Add this Code in Your Template
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Name of Widget') ) : ?>
<?php endif; ?>
I am having some problems trying to get a custom page to display on my site. What I want is to create a page where the client can edit the content in Wordpress. When I add the page using the Wordpress "add new page" it doesn't show, but if I create a page in .php with the same content, it works fine. This is what I did:
First I created a blank .php template called lefthome.php using the following code:
<?php
/*
Template Name: Left Template
*/
?>
<?php get_template_part( 'loop', 'page' ); ?>
I then went into Wordpress, clicked on pages > add new. I gave my page a title and added the content I wanted to appear on the page. Then from the template option in the page attributes I choose the template I had earlier created (Left Template) and clicked update.
I wanted this template to appear on the homepage, so I tried to add it to the homepage template I had created using the following code:
<?php
/*
Template Name: Home
*/
get_header(); ?>
<?php include (TEMPLATEPATH . '/slider.php'); ?>
<div id="content">
<?php include (TEMPLATEPATH . '/lefthome.php'); ?>
</div>
<?php get_template_part( 'loop', 'page' ); ?>
<?php get_footer(); ?>
The header, slider.php and footer all show fine. The contents of the lefthome.php do not appear. I do not know how to get it to show. The only way I have got it to show is to paste the contents into the lefthome.php template. I don't want to do this though, as the client will not be able to edit the contents themselves.
I hope someone can help me.
Thanks
You won't be able to display the content of a page just by calling directly its template file. You need to query the page itself. In that matter it won't matter what template you've already assigned to it anymore.
<?php
/*
Template Name: Home
*/
get_header(); ?>
<?php include (TEMPLATEPATH . '/slider.php'); ?>
<div id="content">
<?php
global $post;
$page_id =5; // 5 is the id of the page we want to present with Left Template.
$post = get_post( $page_id );
setup_postdata( $post );
include locate_template( 'lefthome.php' );
wp_reset_postdata(); // we are done with that. reset the query so the rest don't mess up
?>
</div>
<?php get_template_part( 'loop', 'page' ); ?>
<?php get_footer(); ?>