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!
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
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!
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))) { ?>
Jacorre
Member
Posted 5 months ago #
Saw the mistake I was making thanks!