Support » How-To and Troubleshooting » List articles from a specific category

List articles from a specific category

  • 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).

    $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 {
    <?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


    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

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

    Moderator 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);

    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.