WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Can you echo a custom panel option value within a function? (5 posts)

  1. Jacorre
    Member
    Posted 3 years ago #

    Is it possible to echo the value of a custom panel option within a function?

    For example, if I'm using a query_posts function, can I pass in the values of a custom panel option to the argument of cat?

    Custom Panel Option Values = 1,2,3,4
    query_posts(cat=(echo values here))

    Same idea when using an if statement and in_category(array(echo values here)).

    Thanks!

  2. David Gwyer
    Member
    Posted 3 years ago #

    Sure, you can do something like:

    // assign the variable as current category
    $categoryvariable = $cat;
    
    // concatenate the query
    $args = 'cat=' . $categoryvariable . '&orderby=date&order=ASC';
    
    // run the query
    query_posts( $args );

    See here for more examples:

    http://codex.wordpress.org/Function_Reference/query_posts

  3. Jacorre
    Member
    Posted 3 years ago #

    Ah I was trying to echo right within the query posts instead of assigning the arguments as variables first. I'll give that a try thanks!

  4. Jacorre
    Member
    Posted 3 years ago #

    Doesn't seem to be working when using in_category(array($cats)).

    I have the following:

    <?php
    $cats = get_option('mycats');
    if (!in_category(array($cats))) { ?>
  5. Jacorre
    Member
    Posted 2 years ago #

    Saw the mistake I was making thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic