• hello,

    <?php query_posts('cat=4&showposts=1'); ?>
    <ul style="list-style-type:none;">
    <?php while (have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
    <?php endwhile;?>

    I use the above code to call a post title from a specific category. It works fine with the custom page templates. However, when I insert the code into a wordpress page, the code does not show up the title. What do I need to do to let wordpress recognize the code.

Viewing 1 replies (of 1 total)
  • use

    <?php
    //Query 5 recent published post in descending order
    $args = array( ‘numberposts’ => ‘5’, ‘order’ => ‘DESC’,’post_status’ => ‘publish’ );
    $recent_posts = wp_get_recent_posts( $args );
    //Now lets do something with these posts
    foreach( $recent_posts as $recent )
    {
    echo ‘Post ID: ‘.$recent[“ID”];
    echo ‘Post URL: ‘.get_permalink($recent[“ID”]);
    echo ‘Post Title: ‘.$recent[“post_title”];
    //Do whatever else you please with this WordPress post
    }
    ?>

    or here : http://www.tipsandtricks-hq.com/query-or-show-a-specific-post-in-wordpress-php-code-example-44

Viewing 1 replies (of 1 total)
  • The topic ‘call a specific category post title into a page.’ is closed to new replies.