0

I'm trying to show posts from a certain category on a page like his:

<?php query_posts('category_name=category1'); ?>
            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

This works. However, I'd like 'category1' to be taken from a custom field of the page. Something like this (incorrect code incoming):

<?php query_posts('category_name=get_post_meta(get_the_ID(), 'custom_cat_name', TRUE); ?>'); ?>
            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

How could I make this possible?

1 Answer 1

2

Use it in this way:

$custom_cat_name = get_post_meta(get_the_ID(), 'custom_cat_name', TRUE);
query_posts('category_name=' . $custom_cat_name);

Hope this helps!

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.