homepage Welcome to WebmasterWorld Guest from 54.82.122.194
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Website
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

    
Showing Specific Post
Need to show a specific post in the home page content
calvinmicklefinger




msg:4361430
 3:29 pm on Sep 12, 2011 (gmt 0)

I have a Wordpress theme called "NewsTube" from "Theme-Junkie" (http:\\theme-junkie.com) that shows post excerpts in different sections on the home page.

I have installed this theme as a "Multisite" or "Networked" installation, and each new "blog" or "site" will be a replica of a "default" blog or site.

I would like the excerpt of a particular past to appear on the home page of each blog or site in place of the most recent, as defined by the theme.

Here is the relevant code from the theme index.php
<!--BEGIN OF FEATURED NEWS-->
<?php if (get_theme_mod('featured') == 'Yes') { ?>
<div id="featured">
<div class="boxleft" style="margin:0px;">

<?php $recent = new WP_Query("cat=".get_theme_mod('featuredcat')."&showposts=1"); while($recent->have_posts()) : $recent->the_post(); ?>

<div class="featuredthumb"><?php tj_thumbnail(featuredthumbw, featuredthumbh); ?>
<div class="featuredpost"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></div>

</div>
<?php endwhile; ?>
</div> <!--end: boxleft-->
<div class="boxright" style="margin:0px;">
<?php $recent = new WP_Query("cat=".get_theme_mod('featuredcat')."&offset=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
<h1><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
<span class="date"><?php the_time('M. j'); ?></span><span class="gray"> | </span><?php tj_content_limit('85'); ?>
<?php endwhile; ?>
<?php $recent = new WP_Query("cat=".get_theme_mod('featuredcat')."&offset=2&showposts=".get_theme_mod('featuredlist')); while($recent->have_posts()) : $recent->the_post();?>
<h2><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<span class="date"><?php the_time('M. j'); ?></span><span class="gray"> | </span><?php tj_content_limit('85'); ?>
<?php endwhile; ?>
</div> <!--end: boxright-->
<div class="clear"></div>
</div> <!--end: featured-->
<?php } ?>
<!--END OF FEATURED NEWS-->


How can I modify that code to only show a particular post in the "boxleft" area?

Replacing
<?php $recent = new WP_Query("cat=".get_theme_mod('featuredcat')."&showposts=1"); while($recent->have_posts()) : $recent->the_post(); ?>
with
<?php $recent = new WP_Query('name=my-post-name')."&showposts=1"); while($recent->have_posts()) : $recent->the_post(); ?>
didn't work.

Any suggestions?

 

lorax




msg:4361519
 6:42 pm on Sep 12, 2011 (gmt 0)

There are at least two ways to do this. You can either request the specific post using the WP_Query function by adding the argument for a page id: 'page_id=7'

OR

You filter the output loop looking for the same (within the while statement).

I'd try the specific request first so the code based on what you have above (and not tested) would be:

<?php $recent = new WP_Query("cat=".get_theme_mod('featuredcat')."&showposts=1,page_id=XX"); while($recent->have_posts()) : $recent->the_post(); ?>


where the XX is the page id of the page you want to display.

Learn more here: [codex.wordpress.org...]

[edited by: lorax at 12:56 pm (utc) on Sep 13, 2011]

calvinmicklefinger




msg:4361578
 8:43 pm on Sep 12, 2011 (gmt 0)

Thanks lorax,

I had tried to read and understand the codex, but wasn't getting anywhere, which am why I posted here.

Seems there is something in this theme that keeps that line from working.

Sigh.

lorax




msg:4361897
 12:57 pm on Sep 13, 2011 (gmt 0)

What are you getting for an output? Anything?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved