logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$20
a php echo inside a loop query?

I'm trying to add a function to my theme options page. I have two loops, one showing all the latest posts, and one in the sidebar, to show only posts from a specific category. My idea was to have the user decide the category by adding its name in the theme options page. To try and make the category changable I've tried this:


<?php query_posts('category_name=<? if ($mmcp_catid) { ?><? echo $mmcp_catid; ?><? } else { ?>News<? } ?>&showposts=10'); ?>


..which is not working. Is it even possible to make this kind of tweak to the query? If so, what I am doing wrong?

This question has been answered.

LeTune | 01/13/11 at 5:48am Edit


(2) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    01/13/11
    7:56am
    Utkarsh Kukreti says:

    <?php query_posts('category_name=' . $mmcp_catid ? $mmcp_catid : 'News' . '&showposts=10'); ?>

    • 01/13/11 7:18am

      LeTune says:

      Thanks for the reply dude, but can't seem to get it to work. I'll let you have a shot at it live, before asking Denzel, since you were first :) shoot me an email and I'll send you the login, sven.salmonsson@gmail.com

  • avatar
    Last edited:
    01/13/11
    6:37am
    Denzel Chia says:

    Hi,

    My version,


    <php
    $cat = $mmcp_catid;
    if(empty($cat)){
    $cat = 'News';
    }
    query_posts("category_name=$cat&showposts=10");
    ?>


    Thanks.

    • 01/13/11 6:38am

      Denzel Chia says:

      Sorry,

      Typo error, use this.



      <?php
      $cat = $mmcp_catid;
      if(empty($cat)){
      $cat = 'News';
      }
      query_posts("category_name=$cat&showposts=10");
      ?>



      Thanks.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.