Skip to content

Instantly share code, notes, and snippets.

@adapicom
adapicom / ifcustomfield.php
Created October 13, 2012 16:58
Print Custom Field IF Custom Field Exists
<?php if(get_post_meta($post->ID, 'single-bottom-ad', true)): ?>
<div id="single-bottom-ad">
<?php echo get_post_meta($post->ID, 'single-bottom-ad', true); ?>
</div>
<?php endif; ?>
@adapicom
adapicom / custommenu
Last active December 11, 2015 06:38
Adds custom menu support to a Wordpress theme
<?php wp_nav_menu( array('menu' => 'Blog Menu' )); ?>
@adapicom
adapicom / gist:4742632
Created February 8, 2013 22:55
WP IF ELSE by Post or Page Array
<?php if (is_single(array(459,16,21))) { ?>
<!-- put code here -->
<?php } else { ?>
<!-- put code here -->
<?php } ?>
@adapicom
adapicom / gist:5502655
Created May 2, 2013 14:39
Strip Images from a Wordpress Blog Post
<?php
echo preg_replace('/<img[^>]+./','',get_the_content());
?>
@adapicom
adapicom / gist:5503828
Created May 2, 2013 17:26
Input Placeholder For Older Browsers (jQuery)
<script>
// This adds 'placeholder' to the items listed in the jQuery .support object.
jQuery(function() {
jQuery.support.placeholder = false;
test = document.createElement('input');
if('placeholder' in test) jQuery.support.placeholder = true;
});
// This adds placeholder support to browsers that wouldn't otherwise support it.
$(function() {
if(!$.support.placeholder) {
@adapicom
adapicom / functions.php
Created May 29, 2013 21:30
Strip wpautop for Shortcodes
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
@adapicom
adapicom / gist:5681188
Created May 30, 2013 20:59
Add this to wp-config.php file to disable core, plugin and theme updates and editing.
/** Preventing Core, Plugin and Theme Auto Updates. */
define( 'DISALLOW_FILE_EDIT', true );
define( 'DISALLOW_FILE_MODS', true );
@adapicom
adapicom / gist:5681209
Created May 30, 2013 21:00
Add this to your functions.php file to strip all mentioning of the Wordpress version.
/* REMOVE WORDPRESS VERSION TEXT */
function wpbeginner_remove_version() {
return ''; }
add_filter('the_generator', 'wpbeginner_remove_version');
@adapicom
adapicom / gist:5681247
Created May 30, 2013 21:07
Disable "wrong username" and "wrong password" text on wp-login.php
add_filter('login_errors',create_function('$a', "return null;"));
@adapicom
adapicom / gist:5736531
Created June 8, 2013 20:48
Get an RSS Feed inside Wordpress Theme
<ul>
<?php if(function_exists('fetch_feed')) {
include_once(ABSPATH . WPINC . '/feed.php');
$rssfeed = get_post_meta($post->ID, 'rssfeed', true);
$feed = fetch_feed($rssfeed);
$limit = $feed->get_item_quantity(10);
$items = $feed->get_items(0, $limit);
}
if ($limit == 0) echo '<div>The feed is either empty or unavailable.</div>';