• Hi, my problem is this:

    i use custom fields of a page (portfolio_inhalte_kategorie_id) which stands for an article category id.

    Now i want to implement a feature that gives out all the articles in just this category (id).

    <?php
    $portfolio = get_post_custom_values("portfolio_inhalte_kategorie_id");
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    if (get_post_custom_values("portfolio_inhalte_kategorie_id")) {
    $category = (get_post_custom_values("portfolio_inhalte_kategorie_id"));
    } else {
    $category="0";
    }
    $wp_query->query('cat='.$category.'&paged='.$paged);
    
    ?>
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

    my problem: wordpress always spit out all items of all categories and not only my chosen (id).

    I even tested the if cases with simple echo of the chosen custom field id which works. but finally the output of the articles is wrong.

    Any idea? ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    get_post_custom_values needs to be in a loop if you don’t specify a post ID and returns an array so you cannot use it with 'cat='.$category

    Thread Starter ddjjmm

    (@ddjjmm)

    how can i solve it or use another way to take custom fields for listing category’s article?

    Moderator keesiemeijer

    (@keesiemeijer)

    if it’s just one category ID you give as value in the custom field you can use this in your page template:

    $category = get_post_meta($posts[0]->ID, 'portfolio_inhalte_kategorie_id', true);

    Thread Starter ddjjmm

    (@ddjjmm)

    That’s the way i tried too.

    Just the $posts[0]->ID was missing, thanks for help at all!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List articles from a specific category’ is closed to new replies.