php - How to limit a post feed? -
i have php class grabs post rss feed this:
1-post title 2-post image 3-post description 4-post links original
the problem post description long, need limit description few words.
include_once(abspath . wpinc . '/feed.php'); $rss = fetch_feed(' rss url '); if (!is_wp_error( $rss ) ) : $maxitems = 1; $rss_items = $rss->get_items(0, $maxitems); endif; ?> <?php if ($maxitems == 0) echo 'no items'; else foreach ( $rss_items $item ) : ?> <div id="deals"> <b><a href="<?php echo clean($item->get_permalink()); ?>" rel="nofollow" target="_blank"><?php echo $item->get_title(); ?></a></b> <?php echo hapus(clean($item->get_content())); ?> <p style="text-align:center;bottom:0;"><a title="order <?php echo $item->get_title(); ?>" href="<?php echo clean($item->get_permalink()); ?>" rel="nofollow" target="_blank"><img src="<?php bloginfo('template_url');?>/images/check.jpg" alt="<?php echo $item->get_title(); ?>" /></a></p> </div> <div class="clear"></div> <?php endforeach; ?> function clean($result) { $result = trim($result); return $result; } function hapus($result){ $result = str_replace('<tbody>', '',$result); $result = str_replace('<tr>', '',$result); $result = str_replace('<td>', '<p>',$result); $result = str_replace('</td>', '</p>',$result); $result = str_replace('</tr>', '',$result); $result = str_replace('</tbody>', '',$result); $result = str_replace('<strike>', '',$result); $result = str_replace('</strike>', '',$result); $result = str_replace('<table>', '',$result); $result = str_replace('</table>', '',$result); $result = str_replace('</p></p>', '</p>',$result); $result = trim($result); return $result; }
Comments
Post a Comment