Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Center area post/pages » Post-Kicker, -Byline & -Footer »

[SOLVED] How to show single post special category on static home page??


  #1  
Old Mar 17, 2009, 10:52 AM
Shepherd Jim's Avatar
Shepherd Jim
 
301 posts · Feb 2009
Bristol, midcoast Maine USA
I've set up the home/landing page as a static page. Most of what will show on that "Home" will be static "Welcome to our website....etc".

But, in the middle of the page I want to have a "News from the Shop" announcement (might even be in a framed "box").

I thought the "Inline Post" plugin would be the solution, but in order to update what post would show on the page, I would have to go to the Dashboard, edit the page's html, changing the post number contained between the double square brackets "[[post##]]"

That's clunky. I want to be able to publish the "news annoucement" as a post, using a special category. The most recent post in that category will show up in the "News" box on the home page.

I found this code:

<?php
query_posts('showposts=1&cat=3');
while(have_posts()) : the_post();
?>
<ul>
<li><h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

<ul><li><?php the_content_limit(520); ?></li>
</ul>
</li>
</ul>
<?php endwhile; ?>
by Mr. Balkhis at http://www.balkhis.com/web-designs-r...-in-wordpress/.

In the line -- query_posts('showposts=1&cat=3');, the showposts= value sets how many posts will be displayed and cat= value specs which single category the displayed post(s) come from.

This sounds like it will work, but I can't figure out where to put it.
  #2  
Old Mar 18, 2009, 11:04 AM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
Put the following in index.php, for instance right before <?php get_footer(); ?>

PHP Code:
<?php if ( is_front_page() ) { ?>
<?php $my_query 
= new WP_Query('category_name=featured&showposts=5');
while (
$my_query->have_posts()) : $my_query->the_post(); ?>

All the code parts from index.php here, depending on what you want to display
I.e. Post Kicker, Post, Post Footer...

What you put here will be repeated for every post as specified above 
(5 posts from the category "featured")

category_name is the URL name of the category i.e.:
 /.../category/featured/.../ 
and not the category title: 
"Featured"

<?php endwhile; ?>
<?php 
?>
This would display 5 posts from the category "Featured".

Replace <?php if ( is_front_page() ) { ?> with
<?php if ( is_page() ) { ?> to display on all pages
<?php if ( is_page('17') ) { ?> to display on the page with the ID 7

query_posts would be used to modify the main post loop, but that's already being used to display the post (= "Page" page content) on the page.
  #3  
Old Mar 19, 2009, 12:21 AM
Shepherd Jim's Avatar
Shepherd Jim
 
301 posts · Feb 2009
Bristol, midcoast Maine USA
Okay! With what you provided I've figured out how to make a single post (and/or parts thereof) in my "Announcements" category appear either right after the header or right before the footer of my static pages. ...but unfortunately it appears on ALL the pages.

How can I just have the "announcements" post display on the home page and NOT on ALL of the other pages?
  #4  
Old Mar 19, 2009, 07:17 AM
strangelove's Avatar
strangelove
 
29 posts · Feb 2009
Jim,

Provide a link to your blog please. I would like to follow what you are doing with it.

Thanks,

Michael
  #5  
Old Mar 19, 2009, 07:44 AM
Flynn's Avatar
Flynn
 
3,768 posts · Oct 2008
Munich, Germany
Quote:
Originally Posted by Shepherd Jim
Okay! With what you provided I've figured out how to make a single post (and/or parts thereof) in my "Announcements" category appear either right after the header or right before the footer of my static pages. ...but unfortunately it appears on ALL the pages.

How can I just have the "announcements" post display on the home page and NOT on ALL of the other pages?
Sorry, I missed that part. I updated the code above with if ( is_front_page() )

is_front_page works from WP 2.5 on, with a static page set as the the homepage, at Site Admin -> Settings -> Reading -> Front page displays -> A static page
  #6  
Old Mar 19, 2009, 08:42 AM
Shepherd Jim's Avatar
Shepherd Jim
 
301 posts · Feb 2009
Bristol, midcoast Maine USA
Quote:
Originally Posted by strangelove
Jim,

Provide a link to your blog please. I would like to follow what you are doing with it.
<snip>
Ouch! This is like letting someone watch as you try on new underwear -- boxers or briefs?

Please understand that some day "Shepherd Jim dot com" will be my personal blog. But, right now I'm using it as a WP testbed -- trying stuff out in prep for installation on the real website which is now live and visible to the world.

I've attempted on two occasions to create a "local" installation of WP following instructions in the Codex, but both times it got scary and I gave up.
-- Maybe Flynn will type us up an easy to follow and understand "how to"? hint hint --

So, NOTHING on "Shepherd Jim" is real. I've created great blocks of text/content by copying and pasting, pasting and pasting.

http://shepherdjim.com/wp/

Bookmarks

Tags
category, post

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Next post and previous post links on top of single post page error susieswe Atahualpa 3 Wordpress theme 2 Jul 15, 2009 03:58 PM
Problem implementing "How to show single post special category on static home page??" mkny13 Post-Kicker, -Byline & -Footer 6 May 5, 2009 06:21 AM
[SOLVED] Side Bars will not show up anywhere but the home page...posted from Note Pad Jayce Sidebars & Widgets 12 Apr 26, 2009 11:01 PM
How to create a static home page? tomlucas Page & Category Menu Bars 2 Apr 21, 2009 01:47 AM
How do I show | Category: Introduction | Leave a comment | Edit this post on a Page? PerryM Post-Kicker, -Byline & -Footer 2 Apr 17, 2009 10:03 PM


All times are GMT -6. The time now is 06:31 AM.


Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.