WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom page template + the_loop (6 posts)

  1. w2zone
    Member
    Posted 1 year ago #

    Hi guys,
    Im new to wordpress so im havin a quite alot problems. Ive been googling for like an hour to find the solution for my problem but nothing was found so I decided to register in here. My problem is that I've created custom template page file portfolio.php (copied index.php with the_loop). I did set it up as custom template for Portfolio page. The same file (just with another name and without Template name inside) works as home page that shows posts and when i navigate to /portfolio it doesnt show a shit , when i add something b4 the_loop its displayed on the page but when i add it inside the_loop it doesnt work. Any idea's how can I fix it? It's probly any little thing i'vent done but u'll probly answer me in a minute.
    Thanks for reply.

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    see this example http://codex.wordpress.org/Pages#A_Page_of_Posts to give you an idea about what you need to do to show some posts with that page template.

    i.e. you need to add a custom query before the loop;

    http://codex.wordpress.org/Function_Reference/query_posts
    or
    http://codex.wordpress.org/Class_Reference/WP_Query

    what do you want to show on the portfo;io page?

  3. w2zone
    Member
    Posted 1 year ago #

    The 1st one "query_posts" worked , thanks. And I want to show my works in portfolio page based on posts with thumbnails, just to make it quite automative.

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    show my works in portfolio page based on posts with thumbnails

    to get only posts with thumbnails, try to use this in your query:

    'meta_key' => '_thumbnail_id'

    http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

  5. w2zone
    Member
    Posted 1 year ago #

    The thumbnail do work actualy and they worked before so I have no problem with that.

  6. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    to query would simply avoid to call posts which do not have a 'featured image' attached.

    however, if you have no more problems with this topic, please mark it as 'resolved';

    otherwise please describe what still needs to be dealt with.

    thanks ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.