Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've been looking for the same thing, and have found no where which actually answers what you're trying to do, not even this thread. At least here they're close, but they still break some functionality in your question code provided. However, I have been working on this for a few hours, and per usual, the longer you work at it, the simpler the solution turns out to be.</p> <p>I've made an assumption that you're trying to us WP_Query to choose and display posts from a category chosen in your new them options page, like I am. I've discovered that WP_Query doesn't like recursively sifting through categories if you are using a name, but will if you're using cat_ID...not even when using get_cat_ID. So first, here is my WP_Query that appears in my front-page.php</p> <pre><code>&lt;?php $feat1= get_option('twp_feat_cat'); //this is the id of your option in the mega array you setup in functions.php $args=array('cat' =&gt; $feat1,'post_type' =&gt; 'post','post_status' =&gt; 'publish','posts_per_page' =&gt; 2,'caller_get_posts'=&gt; 1); $my_query = null; $my_query = new WP_Query($args); $post_counter = 0; //so I can style last post differently with css if( $my_query-&gt;have_posts() ) { while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); $post_counter++; ?&gt; &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php if ($post_counter == 1) post_class('fourcol first clearfix'); elseif ($post_counter == count( $posts )) post_class('fourcol last clearfix'); else post_class('fourcol clearfix'); ?&gt; role="article"&gt; &lt;header class="article-header"&gt; &lt;h2&gt;&lt;a href="&lt;?php the_permalink() ?&gt;" rel="bookmark" title="&lt;?php the_title_attribute(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;&lt;/h2&gt; &lt;/header&gt; &lt;!-- end header section --&gt; &lt;section class="entry-content clearfix"&gt; &lt;?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post-&gt;ID), 'original' ); $url = $thumb['0']; echo do_shortcode( '[rimg src="' . $url . '"]' ); ?&gt; &lt;?php the_excerpt(); ?&gt; &lt;/section&gt; &lt;!-- end article section --&gt; &lt;footer class="article-footer"&gt; &lt;p class="tags"&gt;&lt;?php //the_tags('&lt;span class="tags-title"&gt;' . __('Tags:', 'bonestheme') . '&lt;/span&gt; ', ', ', ''); ?&gt;&lt;/p&gt; &lt;/footer&gt; &lt;!-- end article footer --&gt; &lt;/article&gt; &lt;?php endwhile; } wp_reset_query(); // Restore global post data stomped by the_post(). ?&gt; </code></pre> <p>This snippet takes the cat_ID from my theme options page and puts it into <code>$feat1</code></p> <p>The only two changes needed to your functions.php from the original are changing this:</p> <pre><code>$wp_cats[$category_list-&gt;cat_id] = $category_list-&gt;cat_name; </code></pre> <p>to this:</p> <pre><code>$wp_cats[$category_list-&gt;cat_ID] = $category_list-&gt;cat_ID; </code></pre> <p>and then modify your selection <code>&lt;option&gt;</code> tag from this:</p> <pre><code>&lt;option&lt;?php if ( get_settings( $value['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $value['std']) { echo ' selected="selected"'; } ?&gt;&gt;&lt;?php echo $option; ?&gt;&lt;/option&gt; </code></pre> <p>to this:</p> <pre><code>&lt;option value="&lt;?php echo $option;?&gt;" &lt;?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?&gt;&gt;&lt;?php echo get_cat_name($option); ?&gt;&lt;/option&gt; </code></pre> <p>I didn't have to put anything in my header.php to get this working. So what this does is instead of using the cat_name, it uses cat_ID, but fills in the user friendly cat_name in the drop down, while still associating each entry to the cat_ID, which I think it what you were looking for. I'm sorry if this was long, late, or not quite what you were looking for, but this is my very first time contributing to the site, and it was this post that got me started when I was looking for the solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload