List categories for author: list_categories function inside list_authors function

Seemed interesting, so here is my version. Not sure about get_user_by(), should be more robust way to get objects for authors. function my_list_authors() { $authors = wp_list_authors( array( ‘exclude_admin’ => false, ‘html’ => false, ‘echo’ => false ) ); $authors = explode( ‘,’, $authors ); echo ‘<ul>’; foreach ( $authors as $author ) { $author … Read more

How to create a widgetized sidebar for every category dynamically?

Not a good thing if you have a lot of categories, so be careful! First, add the following function in functions.php: add_action( ‘widgets_init’, ‘generate_widget_areas’ ); function generate_widget_areas() { //Do not create for uncategorized category $terms = get_categories(‘exclude=1&hide_empty=0’); foreach ($terms as $term) { register_sidebar( array( ‘name’ => ‘Category ‘.$term->name, ‘id’ => $term->slug.’-widget-area’, ‘description’ => ‘Widget area … Read more

Rewrite category wordpress

You can do this with a rewrite rule from within WordPress. Take a look at the documentation for add_rewrite_rule. Something like this: <?php add_action(‘init’, ‘wpse65855_rewrite’); function wpse65855_rewrite() { add_rewrite_rule( ‘^photos/?$’, // the rule regex ‘index.php?taxonomy=category&term=photos’, // where you want the rule to go ‘top’ // the priority. Make this one go first ); } You … Read more

Create product category and keyword search form in woocommerce? [closed]

I just made it for a client, you’ll have to do it on the pre_get_posts action. That means you will add parameters to the WordPress query before it returns the posts. Add this to functions.php: // advanced search functionality function advanced_search_query($query) { if($query->is_search()) { // category terms search. if (isset($_GET[‘category’]) && !empty($_GET[‘category’])) { $query->set(‘tax_query’, array(array( … Read more

404 error on subcategory pages

The cause of this issue for future reference was the ‘.’ in the category base, which was added to resolve a previous issue. Removing this and using /category/postname (per question) works, so will look for an alternative resolution to the category base issue.

Multiple level category drop-down

function parent_child_cat_select() { ?> <script type=”text/javascript”> /* <![CDATA[ */ jQuery(document).ready(function() { jQuery(‘#parent_cat’).change(function(){ var parentCat=jQuery(‘#parent_cat’).val(); // call ajax jQuery.ajax({ url:”/wp-admin/admin-ajax.php”, type:’POST’, data:’action=category_select_action&parent_cat_ID=’ + parentCat, success:function(results) { jQuery(“#sub_cat_div”).html(results); } }); }); }); /* ]]> */ </script> <form action=”<?php bloginfo(‘url’); ?>/” method=”get”> <div id=”parent_cat_div”><?php wp_dropdown_categories(“show_option_none=Select parent category&orderby=name&depth=1&hierarchical=1&id=parent_cat”); ?></div> <div id=”sub_cat_div”><select name=”sub_cat_disabled” id=”sub_cat_disabled” disabled=”disabled”><option>Select parent category first!</option></select></div> <div id=”submit_div”><input … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)