WordPress.org

Ready to get started?Download WordPress

Forums

Using PHP echo to get category number problem (1 post)

  1. knight42
    Member
    Posted 5 years ago #

    Hi all

    I have a random PHP question if anyone can help. Have done a search, but cannot find the right awnser (Maybe Im not looking in the right places mind!!)

    I have 3 loops in different sections of a page, each calling posts from the same category. Im actually giving this template to someone else, so Im trying to make it simple, so I thought rather than have them put the cat number in on three separate lines I would just have one at the top and use a PHP echo to reference it....but I cant do it!!!

    So at the top of the page I have an echo like this

    <?php>

    $foo = "1";
    $bar = "2";

    ?>

    It works as an echo on the page just fine, have tried it. But I cant figure the correct PHP to call it (im new to PHP so this maybe easy I dunno!) I have this at the moment

    <?php $top_query = new WP_Query('showposts=10&cat=<?php echo "$bar"; ?>&offset=1'); ?>

    But it doesnt work.

    If anyone could help I would be most happy. Thanks people!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags