Note that there are some explanatory texts on larger screens.

plurals
  1. POcustom function to be used with recent posts of 2 categories
    primarykey
    data
    text
    <p>I know this may be simple, but I'm still a little new to WP and PHP and can't figure this one out.</p> <p>Originally, the page was pulling recent posts from 1 category into a group of various columns. That was done nicely with a custom function:</p> <pre><code>category_loop('columns', 'Recent Articles', 4); function category_loop($id, $name, $number) </code></pre> <p>The category id was columns, title of section was recent post and it had 4 total posts.</p> <p>Well, now they need it to be pulled form 2 categories - "columns" and "commentary" and, without rewriting all of the current code, I was wondering if there was a way to do something with an array (or anything) to allow for the 2 category $ids to be used in the function.</p> <p>Any help would be greatly appreciated and I can provide more code if necessary.</p> <p>Thanks so much!</p> <p>EDIT: Here is the function itself:</p> <pre><code>} function category_loop($id, $name, $number){ $weather = get_category_by_slug('the-weather'); $acupuncture = get_category_by_slug('acupuncture-after-the-apocalypse'); $letters = get_category_by_slug('letters-from-the-editors'); ?&gt; &lt;div class="category-block"&gt; &lt;div class="category-block-title"&gt; &lt;div style="margin-top: 4px;"&gt; &lt;?php echo $name ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="&lt;?php echo $id ?&gt;-posts" class="category-post-loop"&gt; &lt;?php remove_action('genesis_post_content', 'genesis_do_post_content'); add_action('genesis_post_content', 'do_post_excerpt'); add_filter('genesis_post_title', 'trop_byline_short'); // Columns -- be sure to remove featured posts $args = array( 'category_name' =&gt; $id, 'cat' =&gt; '-'.$weather-&gt;cat_ID.',-' .$acupuncture-&gt;cat_ID.',-'.$letters-&gt;cat_ID, 'orderby' =&gt; 'date', 'posts_per_page' =&gt; $number, 'meta_query' =&gt; array(array( 'key' =&gt; 'featured', 'compare' =&gt; 'NOT EXISTS' )) ); genesis_custom_loop( $args ); remove_filter('genesis_post_title', 'trop_byline_short'); add_action('genesis_post_content', 'genesis_do_post_content'); remove_action('genesis_post_content', 'do_post_excerpt'); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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