I need to echo a value inside a WordPress Query. Here is my query first:
<?php if(have_posts()):?>
<?php query_posts('cat=14&posts_per_page=3');?>
<h1><?php echo get_the_category_by_id(14); ?></h1>
<?php the_content();?>
<?php endwhile;?>
<?php wp_reset_query(); ?>
<?php endif;?>
The value I need to echo is this: <?php echo $tgh_first_category; ?>
I need to echo this in place of where it says “14” – so I need to replace cat=14 and id(14) with that echo.
How would I do this?
So if I get this right you’re basically unfamiliar with the primary PHP syntax rules? Then you should really read up with the documentation on php.net to familiarize yourself with it.
As for your question, your code should become this: