• Hey guys, Im pulling an RSS feed from my forum to display on my homepage. It displays the titles correctly, but I want to truncate the number of characters per post so it doenst take up a long section if the title is long. How do I do that? here is the code Im using

    <?php // Get RSS Feed(s)
    include_once(ABSPATH . WPINC . '/feed.php');
    
    $rss = fetch_feed('https://examplesite.com/rss');
    if (!is_wp_error( $rss ) ) :
    
        $maxitems = $rss->get_item_quantity(5); 
    
        $rss_items = $rss->get_items(0, $maxitems);
    endif;
    ?>
    
    <ul>
        <?php if ($maxitems == 0) echo '<li>No items.</li>';
        else
    
        foreach ( $rss_items as $item ) : ?>
        <li>
            <a href='<?php echo $item->get_permalink(); ?>'
            title='<?php echo 'Posted '.$item->get_date('j F Y | g:i a'); ?>'>
            <?php echo $item->get_title(); ?></a>
        </li>
        <?php endforeach; ?>
    </ul>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Truncating imported RSS Feeds.’ is closed to new replies.