Custom Post Type URL Rewriting?

When you register the custom post type, you have to specify that the rewrite rule shouldn’t be prepended with the existing URL structure. In short, this means that this line in your register_post_type call: ‘rewrite’ => array(‘slug’ => ‘projects’), should turn into this: ‘rewrite’ => array(‘slug’ => ‘projects’,’with_front’ => false), For more info, check out … Read more

How to Add Tags to Custom Post Type?

Like this: (Where it says “portfolio” is where you register the taxonomy to a post type add_action( ‘init’, ‘create_tag_taxonomies’, 0 ); //create two taxonomies, genres and tags for the post type “tag” function create_tag_taxonomies() { // Add new taxonomy, NOT hierarchical (like tags) $labels = array( ‘name’ => _x( ‘Tags’, ‘taxonomy general name’ ), ‘singular_name’ … Read more

Pagination not working with custom loop

I’ve run into this problem with PageNavi before. My solution is to hijack the $wp_query variable temporarily and then reassign it after closing the loop. An exmaple: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args=array( ‘post_type’=>’post’, ‘cat’ => 6, ‘posts_per_page’ => 5, ‘paged’=>$paged ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); /* … Read more

Extending the search context in the admin list post screen

I solved filtering the query by adding the join on the postmeta table and changing the where clause. tips on filtering the WHERE clause (often require regular expression search&replace) are here on codex: add_filter( ‘posts_join’, ‘segnalazioni_search_join’ ); function segnalazioni_search_join ( $join ) { global $pagenow, $wpdb; // I want the filter only when performing a … Read more

Should I use custom post types or a custom database tables for plugin development?

You should be skeptical of anyone who says that there is a single “right” way. The right way depends on the situation. Using the CPT infrastructure has a number of notable benefits: You get the Dashboard UI for free You automatically take advantage of WP’s caching, including any persistent cache plugins that the installation may … Read more

Permalinks: custom post type -> custom taxonomy -> post

First, register your taxonomy and set the slug argument of rewrite to shows: register_taxonomy( ‘show_category’, ‘show’, array( ‘rewrite’ => array( ‘slug’ => ‘shows’, ‘with_front’ => false ), // your other args… ) ); Next, register your post type and set the slug to shows/%show_category%, and set has_archive argument to shows: register_post_type( ‘show’, array( ‘rewrite’ => … Read more

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