I am using the following codes to show post-info in genesis. but i have an issue. I don’t want to show post-info at some specific pages like blog page and homepage.
so i have tried some ways but not working.
actually i have created page templates .. page-blog.php and page-home.php
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
add_action( 'genesis_before_post_title', 'child_post_info' );
function child_post_info() {
if (!is_page('blog')) {
return;
?>
<div class="post-info">
<span class="date published time">
<time class="entry-date" itemprop="startDate" datetime="<?php echo get_the_date( 'c' ); ?>" pubdate><?php echo get_the_date(); ?></time>
</span> By
<span class="author vcard">
<a class="fn n" href="<?php echo get_the_author_url( get_the_author_meta( 'ID' ) ); ?>" title="View <?php echo get_the_author(); ?>'s Profile" rel="author me"><?php the_author_meta( 'display_name' ); ?></a>
</span>
<span class="post-comments">· <a href="<?php the_permalink() ?>#comments"><?php comments_number( 'Leave a Comment', '1 Comment', '% Comments' ); ?></a></span>
<?php // if the post has been modified, display the modified date
$published = get_the_date( 'F j, Y' );
$modified = the_modified_date( 'F j, Y', '', '', FALSE );
$published_compare = get_the_date( 'Y-m-d' );
$modified_compare = the_modified_date( 'Y-m-d', '', '', FALSE );
if ( $published_compare < $modified_compare ) {
echo '<span class="updated"><em>· (Updated: ' . $modified . ')</em></span>';
} ?>
</div>
<?php }
}
please give me some idea how can i resolve this issue.
NOW:
I have created a new file meta-postinfo.php
and save the
<div class="post-info">
...
</div>
and in functions.php file..
remove_action( 'genesis_before_post_content', 'genesis_post_info' );
add_action( 'genesis_before_post_title', 'child_post_info' );
function child_post_info() {
if ( !is_home() && !is_page(array('blog', 'inspiring quotes')) ) {
get_template_part('meta', 'postinfo');
};
}
the above code is working with blog page as well as home page, but not with ‘inspiring quotes‘ page although i have tried
if ( !is_home() && !is_page('blog') && !is_page('inspiring quotes') ) {
but not working .. do u have any idea?
To hide a given function in a template from particular pages you use the is_page() function like this (to hide a page with the about slug):
To hide something from the home page you use is_Home
See: http://codex.wordpress.org/Function_Reference/is_page and http://codex.wordpress.org/Function_Reference/is_home
EDIT: This would not be in a function called by add_action but instead could be written right into your template where ever it should display, like:
If it was going to be used in multiple templates you can move it to a seperate file and use like: