Display WordPress Posts as a News Ticker

The following tutorial will display your latest posts in a news ticker format. The code is basically the same as my popular post Display Your Latest Posts on a Static Page except that the output is in a unordered list for the jQuery news ticker to work. This tutorial is meant for non WordPress websites to access their WordPress powered blog although it can be easily adapted to work in WordPress pages and posts.

News Ticker

Prerequisites

A PHP web server or hosting, preferably a Linux server running WordPress, although this works with other servers. Please Note: This will not work if your blog is on a different server. A little knowledge of PHP, HTML and CSS is recommended but not required. We will be using the jQuery News Ticker script.

Download Source Files


Download WOW News Ticker

Retrieving the WordPress Posts

In order to retrieve our blog posts we require to link to the WordPress blog header. At the very top of your page add the following above the doctype.

Please Note: The path has to be relative so you can’t link to the file directly using http://

Now in the body (<body></body>) section you need to add the following snippet of code to retrieve the posts.

Adding the jQuery News Ticker

Upload ticker-style.css and news_ticker.min.js to your server. Add the following in-between the opening and closing head tags (<head></head>) in your page.

Underneath, still in-between the opening and closing the head tags, you want to add a little bit of jQuery to initialize the news ticker script

The news ticker script comes with various settings, if needed.

You can style the CSS to suit your needs.

Conclusion

For a more in-depth detail please read index.php in the zip file. If you are having any trouble please feel free to leave a comment or email me. I would like to thank the Rhodri George for creating the jQuery News Ticker script.

Related Posts

  • Pamplemousse

    Hello, the_permalink(); do not return friendly URL, how can i do to display them ?

    • http://worldoweb.co.uk Ridgey

      Have you got friendly URLS set in WordPress Admin? Under Permalink in settings menu

      • Pamplemousse

        Yes it set with the postname. htaccess working. but the url is /?p=xxx

      • http://worldoweb.co.uk Ridgey

        I will test it out myself and let you know.

      • http://worldoweb.co.uk Ridgey

        Strange the permalink is fine on mine! Can you provide a URL so I can take a look?

      • Pamplemousse

        Ok it’s working. I was testing displaying draft post only. they appear not friendly. but published article appear friendly, so it’s good for me! :)
        Thanks for helping me!

  • troy

    Actually Tracy, I think I’m looking for something different.
    I would like to add my posts on my front page of my wordpress website, without changing my default settings to posts only on the home page, As I have it set up purposly to only show my static page.
    I would like it to work like this.

    Page structure below:
    Static home page
    ————————-
    posts that go in order here and get updated anytime i post in my blog area.
    End of page

    I know some things are not taking your time to help so that understandable.
    Sorry i hate time suckers who want everything for free, lol
    peace.

    • http://www.worldoweb.co.uk/ Tracy Ridge

      So you don’t need the ticker then? There are a couple of ways of doing it. The best way would be to create a new PHP page in your theme folder and copy the contents of page.php on to it. This saves page.php for using with future static pages.
      Add the following to it at the top to give the page a name:

      < ?php
      /*
      Template Name: Homepage //change to a suitable name, if needed
      */
      ?>
      

      Personally I would remove the loop from it and add the code to it directly instead of editing it through WordPress pages as you would have to install a plugin that executes PHP.

      Create a new page inside the wp-admin then change the Page Attributes to the new page template.

      Change the WP settings to use this page as a front page, I would recommend doing this last as you do not want to mess up a production site. You can always preview the page until you get it right.

      This may be tricky at first to do as all themes have different structures and CSS. I have used an example from the TwentyEleven theme for you to have a look at.
      Checkout: http://pastebin.com/SuHEi6pQ

      If you get stuck give me a shout or email me your URL and I will check it out.

      • troy

        Thank you so much! I cant believe this.
        I will have to give it a whirl.

  • Troy

    Tracy, Thank you! I tweeted this out for you. I also followed you on Twitter.
    This is so valuable. I’ll read the directions and well see how it goes. I’m going to stumble this page for you as this is a real benefit for everyone. Your awesome! & you know it:)

  • Troy

    I asking the same thing too basically. Thanks tracy.

    • http://www.worldoweb.co.uk/ Tracy Ridge

      I will configure it for WordPress and let you know the results.

      • http://www.worldoweb.co.uk/ Tracy Ridge

        I have included a little mini tutorial on how to add it to WordPress in the source files.

      • troy

        Tracy, I looked at the source files there was nothing in there to open for instructions.. please let me know, thanks.

      • http://www.worldoweb.co.uk/ Tracy Ridge

        File named WordPress.php. You can open it with an IDE or code editor to preserve all the code and make it readable.

  • Vicky

    Hi Tracy

    Amazingly detailed and helpful tutorial I would like to attempt this on my WordPress powered site to display posts (from another page within my website) in the news ticker on my homepage (static) . You mentioned in your opening paragraph that this tutorial can be easily adapted to do so – please could you explain how?

    Thanks,
    Vicky

    • http://www.worldoweb.co.uk/ Tracy Ridge

      Hi Vicky. Are you using a custom theme? What is your URL?