WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to feed WP data to the main index.php page (4 posts)

  1. vikonic
    Member
    Posted 4 years ago #

    Hello there, I'm trying to pull off something interesting here and I'm stuck. Let me begin by saying I am by no means a coder and my PHP experience is 0. I am pretty good with xhtml and css though.

    Anyways, I have an index.php page, that displays the homepage of my website. Banner, navigation, etc is all located here. What I would like is to feed the 'latest # of posts' into the news <div> tag, which I think I already know how to do. Problem is that I also want to feed another piece of information such as Top 10 Songs, that would get updated frequently, into my sidebar.

    What would be the simplest way to create a 'top 10' page in WP and then feed it over into a <div> tag in my sidebar?

    Sorry if it sounds confusing, I'll simplify as needed.

    Thanks.

  2. e-sushi
    Member
    Posted 4 years ago #

    The simples way? Put it in the template. Another way would be to "inject" an external file.

    Let's say you have a html-snippet with your top-10 stored in a file called "top10.txt", then you can use php to "read and inject" it into the page like this:

    <?php echo(file_get_contents('./top10.txt')); ?>
  3. zet_kr
    Member
    Posted 4 years ago #

    You could categorize the posts in different categories when you post them,(say "songs" and "events") and then call for the "songs" in one DIV and "events" in the other DIV.

  4. vikonic
    Member
    Posted 4 years ago #

    Wow, very useful reply guys, thanks a lot. I'm marking this one solved :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.