First, change your code into the following:
$value = get_option( 'mytheme_value' );
query_posts ( "meta_key=post_views_count&orderby=meta_value_num&order=DESC&meta_value={$value}");
When you use single quotation marks, php isn't parsed in the string, and functions (like get_option
) will never be called from within a string. Therefore, call the function get_option
first, and put the value in a double quoted string (which parses variables during execution).
Then change your other code into the following:
// ADD THE FORM INPUT TO $new_post ARRAY
$new_post = array(
'post_title' => $title,
'post_content' => $description,
'post_category' => array($_POST['cat']), // Usable for custom taxonomies too
'tags_input' => array($tags),
'post_status' => get_option( 'mytheme_status' ),
When you want to call a function inside an array, using whatever it returnes as value, you don't need to put the function inside single quotes.
Furthermore, if you want to get option values in functions.php
, you can simply use the following line:
$mytheme_status = get_option( 'mytheme_status' );
When you still encountering errors after these modifications, and you still get a blank screen, try to find out whats going wrong by looking in your error logs. On a linux environment, the default apache error log file location is /var/log/apache2/error.log
or /var/log/httpd/error_log
.