Problems with explode [closed]

It’s because you’ve created an array with explode and assigned it to $string, then you’re appending strings onto it when you use the .= concatenation operator within your foreach loop. here’s a simpler method: $string = ‘-‘ . implode( ‘,-‘, explode( ‘ ‘, $data[‘exclude_categories’] ) );

Search functionality with multiple categories

Sounds like something Relevanssi could handle. With Relevanssi, you’d have the checkboxes to choose the categories. Then, you’d write a function to hook on ‘relevanssi_modify_wp_query’ filter, where you’d read the checkboxes and convert them to a comma-separated list of category ID’s. That you would store in $wp_query->query_vars[‘cats’] and hey presto, Relevanssi gives you relevant results … Read more

Restrict category choice in dropdown menu?

Well after thinking about this some more, I’ve realised that it was a bit of a dumb question to ask… My problem is actually being able to pre-define categories in themes for new subsites of my mulitiste. I’ve got around this by using a premium plugin which allows me to offer blog templates / themes … Read more

Exclude Specific Categories?

You could do it like this: <?php $exclude = array( ‘home-featured’ ); foreach( get_the_category() as $category ) { if ( ! in_array( $category->cat_name, $exclude ) echo $category->cat_name . ‘ ‘; } ?>

List products from current category

Your best bet to do this would be to add a filter/hook on the specific tag. See this snippet at the WooCommerce API docs site on excluding a category for the proper format and to get going in the right direction. http://wcdocs.woothemes.com/snippets/exclude-a-category-from-the-shop-page/ But if you want a down and dirty way to filter for a … Read more

Using pagination with multiple loops causes it to break

The first problem can be solved by changing the query_posts in your work section. Replace ‘&category_name=work’ with ‘&category_name=work&paged=1&posts_per_page=-1’ For the second problem, why not use the category template itself in place of index.php? As a side note, you should not use query_posts for this use case. In place of that you should use a new … Read more

Reversing the order of items in a category rss feed?

In your functions.php file function reverseorder($query_string) { return query_posts( $query_string . ‘&order=ASC’ ); } add_action( ‘rss2_head’, ‘reverseorder’ ); EDIT GET parameters on RSS feed cat – category ID (e.g. 23) author – author ID (e.g. 14) year – year the post was published (e.g. 2007) day – day of the month the post was published … Read more