Jump to content

code adds extra output???


acsonline

Recommended Posts

Hey Guys,

 

I've got a small script that displays latest news.

 

It is supposed to show just the title of the news item in a list, however it shows the content at the bottom of the code...

This is my page

<ul>
<?php
        $args= array(
        'news_items' => 500,
        'title' => TRUE,
        'content' => FALSE,
        'before_title' => '<li>',
        'after_title' => '</li>'
   );

jep_latest_news_loop($args);
echo '</ul>';
?> <br>TEST<br>

 

But this is the output

    * February 2011 Newsletter

    * January 2011 Newsletter

    * December 2010 Newsletter

    * November 2010 Newsletter

    * October 2010 Newsletter

    * New Website Launched

 

 

TEST

February 2011 Newsletter January 2011 Newsletter December 2010 Newsletter November 2010 Newsletter October 2010 Newsletter XXX XXXXX are pleased to announce the launch their new website today. We hope you find it easy to use and informative. Please feel free to contact us with any queries.

 

This is the code generator page

<?php
add_action('init', 'jep_latest_news_init');
function jep_latest_news_init() 
{
  // Create new Latest-News custom post type
    $labels = array(
    'name' => _x('Latest News', 'post type general name'),
    'singular_name' => _x('Latest News', 'post type singular name'),
    'add_new' => _x('Add New', 'Latest News'),
    'add_new_item' => __('Add New Latest News'),
    'edit_item' => __('Edit Latest News'),
    'new_item' => __('New Latest News'),
    'view_item' => __('View Latest News'),
    'search_items' => __('Search Latest News'),
    'not_found' =>  __('No Latest News found'),
    'not_found_in_trash' => __('No Latest News found in Trash'), 
    '_builtin' =>  false, 
    'parent_item_colon' => ''
  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'exclude_from_search' => false,
    'show_ui' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => 20,
    'supports' => array('title','editor','author','thumbnail','excerpt','comments'),
    'taxonomies' => array('category', 'post_tag')
  ); 
  register_post_type('latest-news',$args);  
}

/*
Template function to output the latest news stories
*/
function jep_latest_news_loop($args = null)	{
$defaults = array(
	'news_items' => 500, 
	'title' => TRUE,
	'content' => FALSE, 
	'before_title' => '<li class="h3">',
	'after_title' => '</li>', 
);

global $paged;

$r = wp_parse_args( $args, $defaults );
  	
$qargs=array(
   	'post_type'=>'latest-news',
   	//'posts_per_page' => $r[news_items],
	//'paged' => $paged
);

query_posts($qargs);

while ( have_posts() ) : the_post(); 
?>
<?php echo($r[before_title]);?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php echo($r[after_title]);?>
<?php endwhile;
}
?>

 

Any ideas what is dumping the extra code?

Link to comment
https://forums.phpfreaks.com/topic/230190-code-adds-extra-output/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.