Custom post type archive with pagination?

As you can see in the rewrite analyzer, /projects/page/2/ sets projects=page&page=/2 instead of pagename=projects&paged=2 as we would like. So you just need to add a rewrite rule for this special case (in the register_projects() function, after you register your custom post type, would be a good place): add_rewrite_rule( ‘projects/page/([0-9]+)/?$’, ‘index.php?pagename=projects&paged=$matches[1]’, ‘top’ ); Remember to flush … Read more

Sort category page with custom field

I added the query_posts so we can tell WordPress of a modified query to run. $query_string will let us add onto the current parameters. orderby, meta_key, order let us define the query by telling it how to sort the results More information on ordering by parameters <?php wp_reset_query(); ?> <div id=”content”> <div id=”postFuncs”> <div id=”funcStyler”><a … Read more

Show Custom Post Type by Author

You will need to filter ‘author_link’ to conditionally add the parameter that can be used to add the custom post type into the query for the author’s posts. add_filter( ‘author_link’, ‘myprefix_author_link’, 10, 3 ); function myprefix_author_link( $link, $author_id, $author_nicename ) { if ( is_singular( ‘myCPT’ ) || is_post_type_archive( ‘myCPT’ ) ) { $link = add_query_arg( … Read more

How to pass posts_per_page and paged params query vars to custom taxonomy archive urls?

If I try to add &posts_per_page=15 to url, it doesn’t work: it won’t change number of post. I wonder if you’re looking for a custom query variable, e.g. ppp, to change the number of posts for the main query: add_filter( ‘query_vars’, function( $vars ) { $vars[] = “ppp”; return $vars; } ); add_action( ‘pre_get_posts’, function( … Read more

How to Change Author Posts URL

You can accomplish this with the following rewrite rule ( you’ll want to add this in your functions.php add_rewrite_rule( ‘author/([0-9]+)/?$’, ‘index.php?author=$matches[1]’, ‘top’ ); Be aware that you might need to flush your rules for it to become active. You can do this with rewrite plugin.

Custom Permalinks for Custom post Type Archives?

Take an example custom post type called movie the code below will create custom permalinks awesomemovies/ regardless of the one created by using the has_archive and rewrite options of register_post_type. add_filter( ‘rewrite_rules_array’, ‘custom_permalink_for_my_cpt’ ); function custom_permalink_for_my_cpt( $rules ) { $custom_rules = array(); // for archive urls $custom_rules[‘awesomemovies/?$’] = ‘index.php?post_type=movie’; // for individual post urls e.g: … Read more

Including post_type = ‘wiki’ in author archives

Author archives default to searching for posts of the post type post. You could override this with wiki like so; function wpse_11210_set_wiki_for_author( $query ) { if ( $query->is_main_query() && $query->is_author() ) $query->set( ‘post_type’, ‘wiki’ ); } add_action( ‘pre_get_posts’, ‘wpse_11210_set_wiki_for_author’ ); Drop it in your a plugin or your theme’s functions.php (if the file doesn’t exist, … Read more

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