I’m confused…
For adding different content on a per page basis a couple things come to mind:
1.) Create a widget area and assign widgets on a per page/post basis using widget logic plugin.
2.) Add PHP code to the area I want to effect that is page specific. Example:
<?php if ( is_page('home') ) { ?>
<p>Hey, this is your home page!</p>
<?php } else { ?>
<p>This is NOT your home page!</p>
<?php } ?>
Yes – this should be possible via a custom header.php template file.
// Check to see if the header image has been removed
$header_image = get_header_image();
if ( ! empty( $header_image ) ) :
?>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
to:
// Check to see if the header image has been removed
$header_image = get_header_image();
if ( ! empty( $header_image ) ) :
$my_url = esc_url( home_url( '/' ) );
if( is_home() || is_front_page) ) :
$news = get_page_by_title( 'News' );
$my_url = get_page_link( $news->ID )
endif;?>
<a href="<?php echo $my_url; ?>">
WARNING: Untested
Thanks for all your suggestions. Esmi, I tried your code and it gave me an error on this line:
if( is_home() || is_front_page) ) :
I am a designer impersonating a developer, so I don’t know what to try to fix there. Any suggestions?
Hmmm, now I get this error message:
Parse error: syntax error, unexpected ‘:’ in /…/public_html/dev/wp-content/themes/springers/header.php on line 83
Change this:
$my_url = get_page_link( $news->ID )
…to this:
$my_url = get_page_link( $news->ID );
If you have questions about general PHP syntax, I would recommend reading up at sites such as w3schools.com or PHP.net.
Thanks Chip. I tried that but I still get that same syntax error. Anything other suggestions?
Thanks Chip. I tried that but I still get that same syntax error. Anything other suggestions?
Yes: try w3schools.com or PHP.net to help familiarize yourself with PHP syntax. Since we can’t see your actual code, have no idea what the line numbers refer to in the PHP errors you’re getting, it is next-to-impossible to troubleshoot.
I agree that I need to be more familiar with PHP to work with WordPress. However, I need to figure out how to get it working by tomorrow. Thanks anyway. And thanks for the links.
Send me the your ftp login and password, and your wp-admin login and password and I’ll take a look by tomorrow.
I think it is generally frowned upon to ask for – or to give out – hosting/FTP/WordPress credentials…
webmakerholly,
The correct syntax for the line you’re having problems with is this:
if( is_home() || is_front_page() ) :
Double check that.
Otto, that worked! Thanks! The only thing is now when you’re on the News page, the header links to the News page instead of back to the homepage. (All other pages link back to the homepage though, so that’s good.)
I moved the site to: http://springersgymclub.ca
Thanks for everyone’s help!