Organizing by super-categories (or nested categories)?

Hi @NealWalters: This is obviously more of an opinion question rather than a technical one but here’s my opinion. My advice: use no more than 10 categories. Those <=10 categories when viewed together should define the essence of your blog. Don’t use subcategories. Then use lots of tags to define the topics you are talking … Read more

TwentyTen: Overloading template.php files vs. get_template_part

TwentyTen was designed to help understand the WordPress theming system and that is why it has more lines of comments then actual code. So looking at TwentyTen you need to understand that they tried to include every file in the Template Hierarchy (eg: attachment.php, single.php, page.php) and every template tag there is (including: get_template_part() which … Read more

WordPress Customizer: How can you have multiple active callbacks on one control?

You can create a third active callback function that just references the two existing ones, for example via an anonymous function (PHP≥5.3): // About Block Button Text $wp_customize->add_setting( ‘about_block_button_text’, array( ‘default’ => __( ‘Read More’, ‘my_theme_name’ ) ) ); $wp_customize->add_control( ‘about_block_button_text’, array( ‘label’ => __( ‘About Button Text’, ‘my_theme_name’ ), ‘type’ => ‘text’, ‘section’ => … Read more

How to mass delete one line from all posts

To use phpMyAdmin follow the steps below: Login to phpMyAdmin panel and select your WordPress database. Click on the SQL tab which will bring you to a page with a SQL query box. Once you see the SQL query box, like the image shown below, you can run your SQL query there. UPDATE wp_posts SET … Read more

Default or Preset Content for Custom Post Types

Use the second parameter $post and check $post->post_type alongside a switch, it’s easier and nicer to work with than several if else if else, etc.. add_filter( ‘default_content’, ‘my_editor_content’, 10, 2 ); function my_editor_content( $content, $post ) { switch( $post->post_type ) { case ‘sources’: $content=”your content”; break; case ‘stories’: $content=”your content”; break; case ‘pictures’: $content=”your content”; … Read more

simple wp_insert_post example

// Create post object $my_post = array(); $my_post[‘post_title’] = ‘My post’; $my_post[‘post_content’] = ‘This is my post.’; $my_post[‘post_status’] = ‘publish’; $my_post[‘post_author’] = 1; $my_post[‘post_category’] = array(0); // Insert the post into the database wp_insert_post( $my_post );” This works fine. You code is correct, but it is an problem in the form to send the $_POST … Read more

How to make custom comment fields required and message field not required

Here is a related question that should answer yours. Basicly you want to use the pre_comment_on_post hook function custom_validate_comment() { //validate for brief and rating if( empty( $_POST[‘brief’]) || empty( $_POST[‘rating’]) ) wp_die( __(‘Error: you must fill in both the rating and the brief’) ); //make comment not required if(empy($_POST[‘comment’]){$_POST[‘comment’] == “empty_comment”;} } add_action(‘pre_comment_on_post’, ‘custom_validate_comment’); … Read more