WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Feed to another page (2 posts)

  1. nate51
    Member
    Posted 2 years ago #

    I am working on a site that has a box that normally would have a feed brining in the most recent WordPress blog post. For some reason the posts have stopped updating and the one being displayed on the page is dated back from November 30th 2010. The HTML code being used on the site to import the posts is below

    <?php
    	query_posts(array(
    		'posts_per_page'=>1,
    		'category__in'=>array(4),
    		'category__not_in'=>array(22)
    	)
    	);
    	if(have_posts()){?>
    	<?php the_post();?>
    	<?php
    		$_tmp=get_the_excerpt('');
    		$_tmp=(strlen($_tmp)<250?$_tmp:substr($_tmp,0,250-3)."...");
    		echo "<p>".nl2br($_tmp); ?>
    	<p><a href="<?php the_permalink() ?>">More...</a></p>
    <?php
    	}else{?>
    	<p>No news at this Time, in the meantime <a href="blog">check out our blog</a></p>
    <?php
    	}?>

    I am not sure why the feed isnt updating as new posts are made. Does anyone know what might be going on here or can recommend a better system?

  2. nate51
    Member
    Posted 2 years ago #

    Solved half my own problem, hopefully this will help anyone with the same issue. I found another code to use and mixed and matched with the old code I had so that I could bring in the newest feed from the database but use the styling options from the previous box.

    <?php
    $args = array( 'numberposts' => 1 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
        <?php
    		$_tmp=get_the_excerpt('');
    		$_tmp=(strlen($_tmp)<250?$_tmp:substr($_tmp,0,250-3)."...");
    		echo "<p>".nl2br($_tmp); ?>
        <p><a href="<?php the_permalink() ?>">More...</a></p>
    <?php endforeach; ?>

    Hope this helps anyone with a similar issue.

Topic Closed

This topic has been closed to new replies.

About this Topic