Adding code using functions.php in child theme

You get the $content as a parameter for your function, and you should not echo anything in that function. Return a string instead. Example: add_filter( ‘the_content’, ‘app_bits’); function app_bits( $content ) { if ( ! is_singular() ) { return $content; } $extra=”<div style=”text-align: center;”>custom code goes here</div>”; return $content . $extra; } See How to … Read more

Auto-Tweet if Type is ‘Status’ using OAuth

My guess is that you aren’t hitting the {$old_status}_to_{$new_status} action, which is what you are hooking to with draft_to_published – for new posts there is no guarantee that the “old” status is actually “draft”. Have you tried using the {$new_status}_{$post->post_type} action, which in your case would be publish_status?

is there a way to remove featured image from blog page and single page

If you don’t want to modify the template files directly, you could always make use of the post_thumbnail_html filter: function wpse70960_filter_post_thumbnail_html( $html ) { if ( ( is_home() || is_single() ) { return ”; } else { return $html; } } add_filter( ‘post_thumbnail_html’, ‘wpse70960_filter_get_post_thumbnail_html’ ); This code snippet goes either in your functions.php file or … Read more

Functions Error: Impacting Galleries

You can try to add the condition $query->is_main_query() in your if-sentences so it won’t affect the gallery queries: // Posts per page add_filter(‘parse_query’, ‘wpq_parse_query’); function wpq_parse_query($query) { if(!$query->is_main_query()) { return $query; } if($query->is_archive()) { $query->query_vars[‘posts_per_page’] = get_option(‘to_count_archives’, 1); } if($query->is_home()) { $query->query_vars[‘posts_per_page’] = get_option(‘to_count_home’, 1); } if($query->is_search()) { $query->query_vars[‘posts_per_page’] = get_option(‘to_count_search’, 1); } return $query; … Read more

wordpress get_post_meta give only first value

You have the parameter of get_post_meta set to true which returns single result, set it to false or remove it completely. $dump_array = get_post_meta(get_the_id(), ‘_as_roomname’) //check whats in the array var_dump($dump_array); // or loop for output foreach( $dump_array as $dump ) echo $dump;

Custom HTML markup

Put this in your functions.php: add_shortcode(‘my_blockquote’, ‘my_blockquote’); function my_blockquote($atts, $content) { return ‘<div class=”span3 quote well”>’.PHP_EOL .'<i class=”icon-quote-left icon-2x pull-left icon-muted”></i>’.PHP_EOL .'<blockquote class=”lead”>’.$content.'</blockquote>’.PHP_EOL .'</div>’; } Then, on a page/post, just write: [my_blockquote]Content goes here…[/my_blockquote] and that’s it. // EDIT: To add a quicktag button, put this also in functions.php: function add_blockquote_quicktag() { ?> <script type=”text/javascript”> … Read more