WordPress.org

Ready to get started?Download WordPress

Forums

Custom widget to display specific article category (3 posts)

  1. nemesiss2
    Member
    Posted 1 year 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

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    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

  3. nemesiss2
    Member
    Posted 1 year ago #

    I have installed a php widget from link but still it doesn't work

Topic Closed

This topic has been closed to new replies.

About this Topic