Changing the news ticker from trending news in newspaper wordpress

A great question!

In WordPress, the news ticker or trending news section is often displayed using a plugin or a custom code snippet. Here's a step-by-step guide to help you change the news ticker from trending news to a different type of news feed in a Newspaper WordPress theme:

Method 1: Using a Plugin

  1. Install and activate a plugin like WP RSS Aggregator or FeedWordPress. These plugins allow you to fetch and display news feeds from various sources.
  2. Configure the plugin to fetch the news feed you want to display (e.g., a specific category, tag, or keyword).
  3. In the Newspaper theme's settings, go to Appearance > Customize > News Ticker and select the plugin you installed as the news source.

Method 2: Using a Custom Code Snippet

  1. Create a new file in your theme's directory (e.g., functions.php) and add the following code:
    
    function custom_news_ticker() {
    // Define the news feed URL or query arguments
    $feed_url = 'https://example.com/news-feed'; // Replace with your desired feed URL
    $args = array(
     'post_type' => 'post',
     'posts_per_page' => 5, // Number of news items to display
     'category' => 'your-category', // Replace with your desired category
    );

// Fetch the news feed using WP_Query $query = new WP_Query($args); $news_items = array();

if ($query->have_posts()) { while ($query->have_posts()) { $query->the_post(); $news_items[] = array( 'title' => get_the_title(), 'link' => get_permalink(), 'date' => get_the_date(), ); } }

// Display the news ticker echo '

'; }

// Add the custom news ticker function to the theme add_action('newspaper_news_ticker', 'custom_news_ticker');

2. In the Newspaper theme's settings, go to **Appearance** > **Customize** > **News Ticker** and select the custom function you created as the news source.

**Method 3: Using a Widget**

1. Install and activate a widget plugin like **Widget Logic** or **Widgetize**.
2. Create a new widget and add the following code:
```php
<?php
  // Define the news feed URL or query arguments
  $feed_url = 'https://example.com/news-feed'; // Replace with your desired feed URL
  $args = array(
    'post_type' => 'post',
    'posts_per_page' => 5, // Number of news items to display
    'category' => 'your-category', // Replace with your desired category
  );

  // Fetch the news feed using WP_Query
  $query = new WP_Query($args);
  $news_items = array();

  if ($query->have_posts()) {
    while ($query->have_posts()) {
      $query->the_post();
      $news_items[] = array(
        'title' => get_the_title(),
        'link' => get_permalink(),
        'date' => get_the_date(),
      );
    }
  }

  // Display the news ticker
  echo '<ul>';
  foreach ($news_items as $item) {
    echo '<li><a rel="nofollow" target="_blank" href="'. $item['link']. '">'. $item['title']. ' ('. $item['date']. ')</a></li>';
  }
  echo '</ul>';
?>
  1. Drag and drop the widget to the desired location in your theme's sidebar or footer.

In all cases, make sure to replace the feed_url and args variables with your desired news feed URL and query arguments. You can also customize the news ticker's appearance by modifying the HTML and CSS code.