Filtering a custom post type by custom taxonomy in archive template

Let say you have “book” post type and “genre” taxonomy. And you want to get books with genre of “scifi”. You can pass the parameter in the url using: ?taxonomy=genre&term=scifi Then you can get those parameter using get_query_var(‘taxonomy’) and get_query_var(‘term’) and add them to the WP_Query arguments. $taxonomy = get_query_var(‘taxonomy’); $term = get_query_var(‘term’); $args = … Read more

Adding content to archive and taxonomy pages on custom post types?

First solution can be using the Settings API and create 2 fields “Products Description” and “Usage Description”, after that showing in your template that fields is easy like a: $options = get_option(‘my_theme_options’); echo $options[‘prod_description’]; // echo $options[‘usage_description’]; However, settings API is not the best part of WP core, and probably create a settings page for … Read more

Difference between an archive and a page listing posts

Archive Page An archive page is part of the WordPress Template Hierarchy, and is the template file WordPress uses to display the archive index list for a given post type. The custom post type archive template hierarchy is as follows: archive-{posttype}.php archive.php index.php WordPress uses the query parameters to output this page, and posts are … Read more

How to get category and archive title?

For category use single_cat_title function: http://codex.wordpress.org/Function_Reference/single_cat_title For tag use single_tag_title function: http://codex.wordpress.org/Function_Reference/single_tag_title For date use get_the_date function: http://codex.wordpress.org/Function_Reference/get_the_date For example if you open twentyten theme you will see following: category.php: <h1 class=”page-title”><?php printf( __( ‘Category Archives: %s’, ‘twentyten’ ), ‘<span>’ . single_cat_title( ”, false ) . ‘</span>’ ); ?></h1> date.php: <h1 class=”page-title”> <?php if ( … Read more

Only get_posts of certain post formats

You can’t actually pass a taxonomy-related argument to get_posts(). (Edit: actually, yes you can. The Codex is just somewhat unclear. Looking at source, get_posts() is, at its heart, just a wrapper for WP_Query().) You can pass meta keys/values, and post types, but not taxonomies such as post format. So for this line: $myposts = get_posts(‘numberposts=-1&orderby=post_date&order=DESC’); … Read more

Increase number of posts in archive page

You can use pre_get_posts in your functions file to alter the query function wpsites_query( $query ) { if ( $query->is_archive() && $query->is_main_query() && !is_admin() ) { $query->set( ‘posts_per_page’, 100 ); } } add_action( ‘pre_get_posts’, ‘wpsites_query’ );

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