WordPress.org

Ready to get started?Download WordPress

Forums

Most viewed posts (10 posts)

  1. sanderp
    Member
    Posted 2 years ago #

    Any ideas how to get two separate pages with one with most viewed posts and one with newest posts ?

    By default the main page is the one with newest posts.. but I'd like it to be with most viewed posts..

  2. marv51
    Member
    Posted 2 years ago #

    How do you get the data on how often a page is viewed? WordPress doesn't know. Do you have some kind of plugin?

  3. sanderp
    Member
    Posted 2 years ago #

    No I haven't yet, I'm looking for a solution to manage this.

  4. marv51
    Member
    Posted 2 years ago #

    Maybe http://wordpress.org/support/plugin/top-10 is something for you.

    Or google for "wordpress count page views"

  5. sanderp
    Member
    Posted 2 years ago #

    Okay, I downloaded wp-postviews and found this topic quite similar, but where do I have to add this line of code what user vtxyzzy tells ?

  6. marv51
    Member
    Posted 2 years ago #

    If you want it on your homepage, put it in /wp-content/themes/your-theme/index.php

    put it below the get_header() call.

  7. sanderp
    Member
    Posted 2 years ago #

    Thank you!

    But any idea how I can get a custom page what looks just like my index page but with newest posts first, like normal index page ?

    I tried with new page, but it won't work this way.

  8. marv51
    Member
    Posted 2 years ago #

    Here is what you should do:
    Create a page. Set title. Leave content empty.
    Via FTP copie the index.php file with which it worked before and rename it to page-{slug}.php replace {slug} with the short name/slug of the page you created (what ever is used in the link) upload. Undo any changes you hade to index.php

    Now if you go to the page you just created the new template file should be used.

    You can find detailed information here: http://codex.wordpress.org/Template_Hierarchy

    Please beware that changes made to your theme will be undone by the theme update process. To prevent this from happening, please use a child theme for all you modifications. See info here: http://codex.wordpress.org/Child_Themes

  9. sanderp
    Member
    Posted 2 years ago #

    Okay, when I do this, I get the page, but only with one post and it has the name I gave to the page.

    I can't figure it out why it doesn't give me all the posts just like it should.

  10. marv51
    Member
    Posted 2 years ago #

    You should verify that actually your new template file is used. To do that open that file page-{slug}.php and put something like die("Just testing"); at the beginning of that file. Upload. Now reload the page you created and see if you only see the text "Just testing" in the browser. If so, there is something wrong with that file. If the page does show up normally (maybe try a different Browser or Privat Browsing Mode, just to make sure) the is something wrong with the name of the file.

    Let me know if you have any further problems.

    Marvin

Topic Closed

This topic has been closed to new replies.

About this Topic