You can use conditionals to display whatever you want on certain pages (editing pages.php), on certain single posts (editing single.php) and so on. Example:
<?php if ( is_page(array(2,3,8)) ) { ?>
<div class="box"><div class="featured">
<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>
</div></div>
<?php } ?>
That’s the call for featured content gallery. I did set it to load only on pages 2, 3 and 8 (ID numbers), on other pages it will not load (in the example, it’d be written on pages.php).
Another example, editing index.php:
<?php if ( !is_404() ) { ?>
<div class="box"><div class="featured">
<?php include (ABSPATH . '/wp-content/plugins/featured-content-gallery/gallery.php'); ?>
</div></div>
<?php } ?>
In here I did set it to display on index.php, except if it is a 404 error page.
You can read more about conditionals here:
http://codex.ww.wp.xz.cn/Conditional_Tags
Cheers
Thank you very much!
Quick question, how can I set the ID number on certain pages?
Thanks!
Luke
Alright, so I put in the first code that you placed up there, and changed the file to include to cap.php, but when I go to the page, I get this error:
Warning: include(/cap.php) [function.include]: failed to open stream: No such file or directory in /home/content/s/a/m/samhancock24/html/thecaninedirectory/wp-content/themes/splendour/page.php on line 9
Warning: include() [function.include]: Failed opening ‘/cap.php’ for inclusion (include_path=’.:/usr/local/php5/lib/php’) in /home/content/s/a/m/samhancock24/html/thecaninedirectory/wp-content/themes/splendour/page.php on line 9
This is the exact code that I placed into the page.php:
<?php if ( is_page(array(84)) ) { ?>
<div class="box"><div class="featured">
<?php include ('/cap.php'); ?>
</div></div>
<?php } ?>
Any suggestions?
Thanks
-Luke
Is 84 a page or a single post? If it’s a single post, adapt it below (“is_single”):
<?php if ( is_page('84') ) { ?>
<div class="intro">
<h3> Welcome </h3>
<p> <?php $wel = get_option('spl_welcome'); echo stripslashes($wel); ?></p>
</div>
<div class="logtab">
<?php global $user_ID, $user_identity, $user_level ?>
<?php if ( !$user_ID ) : ?>
<h2>User Login</h2>
<ul>
<li>
<form action="<?php bloginfo('url') ?>/wp-login.php" method="post">
<div class="form-item">
<label> USERNAME</label><br />
<input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" />
</div>
<div class="form-item">
<label> PASSWORD</label><br />
<input type="password" name="pwd" id="pwd" size="22" />
</div>
<input type="submit" name="submit" value="" class="logsub" />
<label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
</form>
</li>
<li><a href="<?php bloginfo('url') ?>/wp-register.php">Create new account</a> — <a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Forgot your password?</a></li>
</ul>
<?php else : ?>
<h2>Admin panel</h2>
<ul class="board">
<li>Welcome <strong><?php echo $user_identity ?></strong>. </li>
<li><a href="<?php bloginfo('url') ?>/wp-admin/">Go to dashboard</a></li>
<?php if ( $user_level >= 1 ) : ?>
<li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Make new post</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-admin/page-new.php">Make new page</a></li>
<?php endif // $user_level >= 1 ?>
<li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">View profile</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Logout</a></li>
</ul>
<?php endif; ?>
</div>
<?php } ?>
It’s a page, and I tried to add the <?php if ( is_page('84') ) { ?> to the top of the code, but it returned some type of parse error that I’m not sure how to solve :/
Using as example the pages.php file from the default theme (your code is between <!-- YOUR HACK STARTS HERE --> and <!-- YOUR HACK ENDS HERE --> ):
<?php
/**
* @package WordPress
* @subpackage Default_Theme
*/
get_header(); ?>
<!-- YOUR HACK STARTS HERE -->
<?php if ( is_page('84') ) { ?>
<div class="intro">
<h3> Welcome </h3>
<p> <?php $wel = get_option('spl_welcome'); echo stripslashes($wel); ?></p>
</div>
<div class="logtab">
<?php global $user_ID, $user_identity, $user_level ?>
<?php if ( !$user_ID ) : ?>
<h2>User Login</h2>
<ul>
<li>
<form action="<?php bloginfo('url') ?>/wp-login.php" method="post">
<div class="form-item">
<label> USERNAME</label><br />
<input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" />
</div>
<div class="form-item">
<label> PASSWORD</label><br />
<input type="password" name="pwd" id="pwd" size="22" />
</div>
<input type="submit" name="submit" value="" class="logsub" />
<label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label>
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
</form>
</li>
<li><a href="<?php bloginfo('url') ?>/wp-register.php">Create new account</a> — <a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Forgot your password?</a></li>
</ul>
<?php else : ?>
<h2>Admin panel</h2>
<ul class="board">
<li>Welcome <strong><?php echo $user_identity ?></strong>. </li>
<li><a href="<?php bloginfo('url') ?>/wp-admin/">Go to dashboard</a></li>
<?php if ( $user_level >= 1 ) : ?>
<li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Make new post</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-admin/page-new.php">Make new page</a></li>
<?php endif // $user_level >= 1 ?>
<li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">View profile</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Logout</a></li>
</ul>
<?php endif; ?>
</div>
<?php } ?>
<!-- YOUR HACK ENDS HERE -->
<div id="content" class="narrowcolumn" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content('<p class="serif">' . __('Read the rest of this page »', 'kubrick') . '</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'kubrick') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
</div>
</div>
<?php endwhile; endif; ?>
<?php edit_post_link(__('Edit this entry.', 'kubrick'), '<p>', '</p>'); ?>
<?php comments_template(); ?>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
P.s.: I showed you how to add that code into specific pages, tho it doesnt mean it’ll run smoothly (it depends on your code, if it’s been written correctly; otherwise it’ll cause errors).