Category foreach Paging

I figured it out! After a lot of research and trial and error, I managed to figure out how to get the paging to work for both versions…my original code and the simplified code update. Original Code Solution: <?php $cat = get_cat_ID(“Photos”); $categories = get_categories(“child_of=$cat”); $limit = 9; $total = count($categories); $pages = ceil($total / … Read more

How can I just show portfolio items from 1 category on portfolio page?

Depending on whether you intend to use this template to display other categories elsewhere, you may need a copy of the Portfolio Template file, named for this category. To select a single category for display, from post type ‘portfolioitems’, modify the following line: $wp_query = new WP_Query(array(‘post_type’ => ‘portfolioitems’,’posts_per_page’ => 50,’paged’=> $paged)); To: $wp_query = … Read more

Wrong category being displayed in URL

just an update: I used the plugin WP Permastructure to solve the issue by adding /%category%/%postname%/ in the “category” section on the bottom of the permalinks settings page (the permalink adds new fields). Not really sure why this works but changing the permalink structure normally does not.

$args Orderby The number

You could use the get_terms_orderby filter: add_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); $categories=get_categories($cat_args); remove_filter( ‘get_terms_orderby’, ‘wpse156153_get_terms_orderby’, 10, 3 ); with function wpse156153_get_terms_orderby($orderby, $args, $taxonomies ) { return ‘FIELD(t.term_id, ‘ . $args[‘include’] . ‘)’; }

Display a category name automatically using code in the functions.php file

Would each post only be in one category? You’d first need to get all the categories associated with the post, and then output only first. Here is an untested example: function add_before_content($content) { $post_cats = get_the_category(); return ‘<p>This post is in the ‘ . $post_cats[0]->cat_name . ‘ category</p>’ . $content; } add_filter(‘the_content’, add_before_content); Reference: http://codex.wordpress.org/Function_Reference/get_the_category

Get posts from 2 or more categories

The ‘category__in’ parameter accepts an array. You’re giving it a string of comma-separated values. Also, you need to use explode() instead of implode(). implode() is for joining array elements with a string, while explode() is for splitting a string by another string. Try this instead: $args = array( ‘category__in’ => array( explode( ot_get_option( ‘beautiful_categories’ ), … Read more

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