Hide content editor for posts after approriate date

function disable_editor_for_old_posts_wpse_101106($post) { if (strtotime(‘-2 months’) > strtotime($post->post_date)) { remove_post_type_support(‘post’,’editor’); } } add_action(‘add_meta_boxes_post’, ‘disable_editor_for_old_posts_wpse_101106′); I couldn’t find a great hook for this but add_post_meta_boxes_* is early enough, and it passes the $post object to the callback. Basically the filter checks the post on the post edit screen and removes post type support based on the … Read more

How do I grab specific posts (by post id) and display the title, featured image, and excerpt?

I have not tested this but based on your question, this should get you on track: <?php $id = 4; // The Page or post ID $page_data = get_post( $id ); $title = $page_data->post_title; $content = $page_data->post_content; $excerpt = substr($content, 0, 155); $featured_image = wp_get_attachment_url( get_post_thumbnail_id($id, ‘thumbnail’) ); ?> <div class=”post”> <h1><?php echo $title; ?></h1> … Read more

Total Word Count For Posts And Comments By One Author

Run a couple of queries and a code snippet to calculate the word count for the post content, comments content and tag names on each post. // This query will return the number of words in the post content $post_qry=”SELECT LENGTH(post_content) – LENGTH(REPLACE(post_content, ‘ ‘, ”))+1 from wp_posts where ID=”.$post_id; // This query will return … Read more

Making an IE only site (Like a Mobile only site)

maybe you can somehow use template redirect? I’m not too clear on how it works, but it may be worth investigating. function my_check_is_ie() { global $is_winIE; if ( ! $is_winIE ) return; // load template for IE include(TEMPLATEPATH . ‘/IE_template.php’); // or maybe? if( is_home() ) include(TEMPLATEPATH . ‘/IE_home.php’); elseif( is_single() ) include(TEMPLATEPATH . ‘/IE_single.php’); … Read more

Unable to get_the_content(); of a post in WordPress via AJAX

get_the_content() must be used inside the loop, or otherwise you’ll need to use setup_postdata(); providing the post object. Try the following: function ajax_action_stuff() { $post_id = $_POST[‘post_id’]; //Query the post and set-up data $post = get_post($post_id); setup_postdata( $post ); update_post_meta($post_id, ‘post_key’, ‘meta_value’); //Return response as an array. This will give us data.title and data.content browser-side. … Read more

Adding short codes from a page’s content on header and hiding the same from page’s content

This might work for you, trying to hook early to the_content filter to strip the shortcode tag from it: add_filter(‘the_content’, ‘ad_filter_the_content’,1,1); function ad_filter_the_content($content) { // specify page id or array of page ids to include if (is_page(5)) { return str_replace(‘[orbit-slider category=”test”]’, ”, $content); } return $content; }

Content only on last page, if the page has pagination

Instead of using the global variables directly, here’s a way to use the content_pagination filter to add custom HTML to the last content page: /** * Append HTML to the last content page, if it’s paginated */ add_filter( ‘content_pagination’, function( $pages ) { if( count( $pages ) > 1 ) $pages[count($pages)-1] .= ‘<div>MY HTML HERE!</div>’; … Read more