Forums

[resolved] Get posts based on page name? (3 posts)

  1. Moongoat
    Member
    Posted 2 years ago #

    Hey,

    I'm a student developer, but not much into php tho ;)
    I'm trying to set up a wordpress with portfolio for myself, but I ran into some problem;

    I'm using a portfolio template as extent to a "Page" called portfolio.
    So far that template uses
    query_posts("category_name=Portfolio&posts_per_page=6&paged=$paged");
    which worked out good enough so far. However, I wanted to add subcategories to the portfolio. Lets say they are called Java and PHP...

    well, at the moment if I extent those pages to the portfolio template, only the posts in the Portfolio category are shown, and not the ones in the "portfolio - JAVA" category.

    Can I somehow change that template so it does something like

    query_posts("category_name=" & super.pagename & "&posts_per_page=6&paged=$paged");
    (I know above variable is BS, but thats just an example)

    hope I explained what I want to do good enough for you to understand...

    Thanks in advance for the help

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    nice idea, this might work:

    $pagename = $post->post_title;
    query_posts("category_name=$pagename&posts_per_page=6&paged=$paged");
  3. Moongoat
    Member
    Posted 2 years ago #

    Thanks, that worked perfect :)

    at first I thought it wasn't, but apparently query_posts() works by using the category slug... after tweaking the slugs, it does work =D

    many thanks

Topic Closed

This topic has been closed to new replies.

About this Topic