Wordpress Themes - WP Forum at BFA
Click here to register or to donate.
Auto self-registration is not available here - far too many spammers. This forum has many, many backlinks and because of that there is an intense desire among spammers to drop their links here.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Sidebars & Widgets »

[SOLVED] query_post in sidebar widget area in php code widget thingy

Old Apr 27, 2011, 12:11 AM
5 posts · Apr 2011
Hi again!

I am really in need of help, I am trying to use the code below to pull the most recent posting content from a category into a left sidebar php widget area

<?php query_posts('category_name=updates&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php the_content(); ?>
<?php endwhile;?>
When I do this it is posting beautifully in the left sidebar but is also overriding my page center content as well and displaying the same post in the center area. Would it be possible to have some guidance with this? I would like my center area content to stay as I have it but also do the query_post content display as I need it to in the left sidebar.

I have already tried to use the plug-in query posts but it is not letting me style it as I need to for this to work, so I am having to resort to hard coding the left widget.

Thank you for your time!
Old Apr 27, 2011, 11:06 AM
lmilesw's Avatar
10,174 posts · Jul 2009
Central New York State USA
What do you mean by "hard coding the left widget"?
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
Old Apr 27, 2011, 02:38 PM
5 posts · Apr 2011
thank you for responding! I appreciate it very much..

First, Hardcoding meaning I am not using a prefab plugin to do what I would like to happen, I am putting actual code in the left side bar widget php widget item. Meaning when I drag it from my widget choices I am putting actual php code and truthfully right now I had to copy and paste my text from the post that I want to use in a text widget for the time being.

Second, when you refer to the loop are you talking about the small section I am using or in the center pages loop? Forgive the noob question I want to make sure that we are on the same "code speak page"

So to be clear I just need to add
<?php wp_reset_query(); ?>
below the following?

<?php query_posts('category_name=updates&showposts=1'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<?php endwhile;?>
Lemme give it a shot, crossing fingers, Will be back with the results!!

Old Apr 27, 2011, 03:14 PM
5 posts · Apr 2011
YAY! IT WORKS!!!... I owe you a bearhug! TY TY TY!



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert php code into widget or sidebar Stingraynut Header configuration & styling 1 Apr 6, 2010 08:25 PM
Can I hard code some text in a new widget area? horsemansarts Sidebars & Widgets 0 Nov 10, 2009 04:59 PM
[SOLVED] Strange problem with PHP Code plugin widget paulae Plugins & Atahualpa 5 Oct 1, 2009 09:43 AM
[SOLVED] PHP code widget destroyed my site! paulae Sidebars & Widgets 0 Jul 13, 2009 06:07 AM
Location for php code for SOCIABLE widget? strangelove Post-Kicker, -Byline & -Footer 1 Feb 18, 2009 06:04 PM

All times are GMT -6. The time now is 05:36 PM.

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