Programming: comments content global plugin post programmatically thematic Wordpress
by bseanvt
8 comments
Programmatically Turn Off Comments in WordPress with Filter
To turn comments off programmatically with a filter in WordPress, you can set the post object’s comment_status variable to “closed”. Call the filter at some point after the post is loaded but before the comments are rendered. This is a hack, but I haven’t seen a simpler approach, beside installing another plugin. In the example below, the condition to disable comments is simple. If a post is in a certain category, comments aren’t allowed. Otherwise, go ahead and behave as normal. You can still disable comments on a per post basis in other categories.
One thing to note is the use of the global $post object. The function needs access to the object to set the variable.
add_filter('get_header', 'sb_turn_comments_off');
function sb_turn_comments_off(){
if(in_category("Projects") AND is_single() ){
global $post;
$post->comment_status="closed";
}
}
I’ve only tested this with the Thematic framework. I assume that other themes will check the comment_status variable before allowing comments.
Programming: child themes frameworks functions reference thematic themes Wordpress
by bseanvt
1 comment
Thematic Function Reference
I could not find a listing of all thematic theme functions for WordPress online. So the following is just a recursive grep of the thematic directory.
grep -rh "function thematic_" *
Each function needs to prepended with “thematic_” when adding as a action or filter eto a WordPress childtheme. Example
function my_function_says_hello(){ print "Hello!"; }
add_filter('thematic_abovepagebottom', 'my_function_says_hello');
Here is the list
remove_generators() abovecomments() abovecommentslist() belowcommentslist() abovetrackbackslist() belowtrackbackslist() abovecommentsform() show_subscription_checkbox() belowcommentsform() show_manual_subscription_form() belowcomments() singlecomment_text() multiplecomments_text() postcomment_text() postreply_text() commentbox_text() commentbutton_text() commenter_link() comments_template() include_comments() abovecontainer() archives() navigation_above() navigation_below() above_indexloop() archiveloop() authorloop() categoryloop() indexloop() searchloop() singlepost() tagloop() below_indexloop() above_categoryloop() below_categoryloop() above_searchloop() below_searchloop() above_tagloop() below_tagloop() belowcontainer() page_title() nav_above() archive_loop() author_loop() category_loop() index_loop() single_post() search_loop() tag_loop() time_title() time_display() postheader() postheader_posteditlink() postheader_posttitle() postheader_postmeta() postmeta_authorlink() postmeta_entrydate() postmeta_editlink() content() archivesopen() category_archives() monthly_archives() archivesclose() 404() 404_content() postfooter() postfooter_posteditlink() postfooter_postcategory() postfooter_posttags() postfooter_postcomments() postfooter_postconnect() nav_below() previous_post_link() next_post_link() author_info_avatar() cats_meow($glue) tag_ur_it($glue) comments($comment, $args, $depth) pings($comment, $args, $depth) body_class( $print = true ) post_class( $print = true ) comment_class( $print = true ) date_classes( $t, &$c, $p = '' ) abovefooter() footer() footertext($thm_footertext) belowfooter() after() subsidiaries() siteinfoopen() siteinfo() siteinfoclose() create_doctype() head_profile() doctitle() create_contenttype() seo() canonical_url() use_excerpt() use_autoexcerpt() create_description() show_description() create_robots() show_robots() create_stylesheet() show_rss() show_commentsrss() show_pingback() show_commentreply() head_scripts() add_menuclass($ulclass) before() aboveheader() header() brandingopen() blogtitle() blogdescription() brandingclose() access() belowheader() trim_excerpt($text) the_excerpt($deprecated = '') excerpt_rss() tag_query() sidebar() abovemainasides() betweenmainasides() belowmainasides() aboveindextop() belowindextop() aboveindexinsert() belowindexinsert() aboveindexbottom() belowindexbottom() abovesingletop() belowsingletop() abovesingleinsert() belowsingleinsert() abovesinglebottom() belowsinglebottom() abovepagetop() belowpagetop() abovepagebottom() belowpagebottom() abovesubasides() belowsubasides() subsidiaryopen() before_first_sub() between_firstsecond_sub() between_secondthird_sub() after_third_sub() subsidiaryclose() search_form() widgets_init() sort_widgetized_areas($content) primary_aside() secondary_aside() 1st_subsidiary_aside() 2nd_subsidiary_aside() 3rd_subsidiary_aside() index_top() index_insert() index_bottom() single_top() single_insert() single_bottom() page_top() page_bottom() before_widget_area($hook) after_widget_area($hook) before_widget() after_widget() before_title() after_title()
Thematic is a nice theme framework for WordPress. More info is available at the developers website ThemeShaper. Using the above filters it is possible to create a highly customized child theme quickly.


