Skip to content

Instantly share code, notes, and snippets.

@ovizii
ovizii / function.php
Created July 28, 2013 08:42
Increase the height of the excerpt
add_action('admin_head', 'so_excerpt_textarea_height');
function so_excerpt_textarea_height() {
echo'
<style type="text/css">
#excerpt{ height:500px; }
</style>
';
}
@ovizii
ovizii / function.php
Created July 28, 2013 08:44
Remove the URL website field from comments
//Remove URL field from comment form
function so_remove_comment_fields($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','so_remove_comment_fields');
@ovizii
ovizii / function.php
Created July 28, 2013 08:53
Add search field to navigation
// ADD SEARCH BOX TO NAVIGATION
function so_add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
ob_end_clean();
$items .= '<li class="nav_search">' . $searchform . '</li>';
return $items;
}
add_filter('wp_nav_menu_items','so_add_search_box', 10, 2);
@ovizii
ovizii / function.php
Last active December 20, 2015 08:09
Enable shortcodes in widgets
// Enable for widget title
add_filter('widget_title', 'do_shortcode');
// Enable for widget text
add_filter('widget_text', 'do_shortcode');
// don't auto-wrap shortcode that appears on a line of it's own
add_filter( 'widget_text', 'shortcode_unautop');
@ovizii
ovizii / wp-config.php
Last active August 23, 2022 06:59
wp-config.php pimping
//disable auto updating of WP since 3.7
//Disables all core updates:
define( 'WP_AUTO_UPDATE_CORE', false );
//Enables all core updates, including minor and major:
define( 'WP_AUTO_UPDATE_CORE', true );
//Enables core updates for minor releases (default):
define( 'WP_AUTO_UPDATE_CORE', 'minor' );
//only disable updating of the wp.content folder, i.e. no themes and default plugins like akismet and hello dolly
@ovizii
ovizii / functions.php
Created August 4, 2013 09:42
Show Post Thumbnail in feeds
// show post thumbnails in feeds
function diw_post_thumbnail_feeds($content)
{
global $post;
if(has_post_thumbnail($post->ID))
{
$content = '<div>' . get_the_post_thumbnail($post->ID) . '</div>' . $content;
}
return $content;
}
@ovizii
ovizii / functions.php
Created August 4, 2013 09:46
Allow upload of more file types
<?php //just need to research the type for each ending
function addUploadMimes($mimes) {
$mimes = array_merge($mimes, array(
'pdf|xls|tmPreferences' => 'application/octet-stream'
));
return $mimes;
}
?>
add_filter('upload_mimes', 'addUploadMimes');
@ovizii
ovizii / functions.php
Created August 4, 2013 09:48
Change excerpt length depending on category
add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($length) {
if(in_category(14)) {
return 13;
} else {
return 60;
}
}
@ovizii
ovizii / page.php
Created August 14, 2013 06:24
Create your own loop
<?php $loop = new WP_Query( array( 'post_type' => 'movies','actors' => 'peter-smith', 'actress' => 'jane-smith', 'posts_per_page' => 10 ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<?php the_title( '<h2 class="entry-title"><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h2>' ); ?>
<h5>image</h5><a href="<?php the_permalink(); ?>"><img src="<?php the_field('image'); ?>" alt="text-here" /></a>
<?php the_excerpt(); ?>
<?php endwhile; ?>
@ovizii
ovizii / functions.php
Created August 15, 2013 09:21
Add comment policy below comment form
function wpbeginner_comment_text_after($arg) {
$arg['comment_notes_after'] = "We are glad you have chosen to leave a comment. Please keep in mind that comments are moderated according to our <a href='http://www.example.com/comment-policy-page/'>comment policy</a>.";
return $arg;
}
add_filter('comment_form_defaults', 'wpbeginner_comment_text_after');