Forums
Home / Fixing WordPress / Custom widget to display specific article category
(@nemesiss2)
11 years, 2 months ago
Hello i have a custom widget and i have placed my own code in it to display articles from a specific category but it doesn’t work.
Here is my code
<div class="latestNews"> <?php query_posts('cat=529&showposts=2'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="postContent" > <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3> <?php echo get_the_excerpt(); ?> </div> <?php endwhile; endif; ?> </div>
Any help will be appreciated.
Regards
Nicos
(@swansonphotos)
Are you using a default text widget? If so, PHP cannot be used in a text widget. Review how to use PHP in a custom widget area here:
http://codex.wordpress.org/Widgetizing_Themes
I have installed a php widget from link but still it doesn’t work