Point homepage to custom php page

Please familiarize yourself with the WordPress templating system, beginning with the Template Hierarchy. In the WordPress template system, a specific template file, front-page.php, is used for a customized site front page. (Note also the nomenclature; in WordPress parlance, the home page refers to the Blog Posts Index, and not to the Site Front Page.) So, … Read more

Archive subtitles for different types of archives

How about using the single_cat_title() function regardless of what type of archive it is? For example: function get_the_subtitle() { if( is_archive() ) { $subtitle=”Blog posts for “; } if( is_category() || is_tag() ) { $subtitle .= single_cat_title( ”, false ); } if( is_author() ) { $curauth = ( get_query_var( ‘author_name’ ) ) ? get_user_by( ‘slug’, … Read more

Custom SELECT Query With Multiple Meta Values (Ordering Problem)

I believe you can achieve this with WP_Query and avoid the custom SQL: $today = date( ‘Y-m-d’ ); $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘ID’, ‘terms’ => 15 ) ), ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘event_enddate’, ‘value’ => $today, ‘compare’ => ‘>=’ ) ), ‘meta_key’ … Read more

Extending core class in plugin

The Widgets API page on the Codex has a great snippet for extending a class (in this case the WP_Widget class). This should be pretty clear overall. Be sure you’re using the standard name of the class and make sure it’s an actual class and not just a function. /** * Adds Foo_Widget widget. */ … Read more

Custom Columns WordPress Admin

first create the new column: add_filter( ‘manage_edit-post_columns’, ‘c3m_new_column’); function c3m_new_column( $defaults ) { $dfaults[‘post_thumbnail’] = ‘Post Thumbnail’; return $defaults; } Now the function to output the thumbnails in the column: add_action( ‘manage_posts_custom_column’, ‘c3m_custom_column’, 10, 2); function c3m_custom_column( $column_name, $post_id ) { if ($column_name == ‘post_thumbnail’) { if ( has_post_thumbnail() ) { $img_url = wp_get_attachment_image_src( get_post_thumbnail_id() … Read more

Semi complicated custom taxonomy question

Start with a tax_query to get posts with the ‘categorie’ taxonomy term you want. Assuming a custom query: $tax_query_args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘categorie’, ‘field’ => ‘slug’, ‘terms’ => array( ‘costa’ ) ), ); $tax_query = new WP_Query( $tax_query_args ); Then, step through that query, and use get_the_terms() to return the … Read more

Search URL parameters query [duplicate]

Your query variable country is not defined, its not part of the standard query_vars set by WordPress, where as both monthnum and year are and that’s why they work and the former does not. So you need to add your query variable into the mix, try the following; function new_query_var() { global $wp; $wp->add_query_var(‘country’); } … Read more

Don’t change Custom Post Type slug to unique value

you might consider the ‘wp_unique_post_slug’ filter: add_filter( ‘wp_unique_post_slug’,’my_disable_unique_slug’,11,6); function disable_unique_slug( $slug, $post_ID, $post_status, $post_type, $post_parent, $original_slug ){ global $post; if($post->post_type==’cpt’){ // EDIT post type $slug=$original_slug; } return $slug; } This is untested, but you get the idea 😉 ps: you might have to change other things to make this work, since the unique-ness is so … Read more