Welcome to WebmasterWorld Guest from 54.234.153.186

Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Showing Specific Post

Need to show a specific post in the home page content

     

calvinmicklefinger

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

10+ Year Member



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

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

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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

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

10+ Year Member



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

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

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



What are you getting for an output? Anything?
 

Featured Threads

Hot Threads This Week

Hot Threads This Month