Skip to content

Instantly share code, notes, and snippets.

View barbwiredmedia's full-sized avatar

Barbara Talbot barbwiredmedia

View GitHub Profile
@barbwiredmedia
barbwiredmedia / Wordpress - Functions
Last active December 20, 2015 11:59
Wordpress - Functions ACF / WP Ecommerce - Post Priority Fix
/* WP e-commerce core has been edited
* ::root::\wp-content\plugins\wp-e-commerce\wpsc-admin\includes\product-functions.php
*
* Line #221 changed priority 10 save to priority 5 was conflicing with ACF BT - 4.29.2013
* add_action( 'save_post', 'wpsc_admin_submit_product', 5, 2 );
*/
remove_action( 'save_post', 'wpsc_admin_submit_product', 10, 2 );
add_action( 'save_post', 'wpsc_admin_submit_product', 5, 2 );
@barbwiredmedia
barbwiredmedia / Wordpress - Functions
Last active December 20, 2015 11:59
Wordpress - Functions: Add Featured Image support to Custom Post types
add_theme_support( 'post-thumbnails', array( 'post', 'page', 'works' ) );
add_image_size( '{image-name}', 290, 144, true );
add_image_size( 100, 85, true );
// Prints function
<?php the_post_thumbnail( '{image-name}' ); ?>
<?php the_post_thumbnail(); ?>
@barbwiredmedia
barbwiredmedia / Wordpress - Function
Last active December 21, 2015 13:19
Wordpress - Functions: Call a Widget with a Shortcode
function widget($atts) {
global $wp_widget_factory;
extract(shortcode_atts(array(
'widget_name' => FALSE
), $atts));
$widget_name = wp_specialchars($widget_name);
@barbwiredmedia
barbwiredmedia / Wordpress - Custom Fields in functions
Last active December 21, 2015 13:19
Wordpress - Functions: Calls a custom field
// Enamble Custom Field output in functions.php
function print_custom_field($custom_field) {
global $post;
$custom_field = get_post_meta($post->ID, $custom_field, true);
echo $custom_field;
}
// Prints function
<?php print_custom_field('{name}'); ?>
@barbwiredmedia
barbwiredmedia / Wordpress - Functions
Last active June 18, 2018 04:30
Wordpress - Functions: CF7 cf7 contact form 7- Validate Phone Numbers and custom matching password
/*add in functions.php
Validate Numbers in Contact Form 7
This is for 10 digit numbers - [phone] for feild
*/
function is_number( $result, $tag ) {
$type = $tag['type'];
$name = $tag['name'];
if ($name == 'phone' || $name == 'fax') { // Validation applies to these textfield names. Add more with || inbetween
@barbwiredmedia
barbwiredmedia / Wordpress - Functions
Created August 22, 2013 20:32
Wordpress - Functions: Create [shortcode]
// Creates a shortcode
function HelloWorldShortcode() {
return '<p>Hello World!</p>';
}
add_shortcode('helloworld', 'HelloWorldShortcode');
//Output on page [helloworld]
@barbwiredmedia
barbwiredmedia / Wordpress - Functions
Created August 22, 2013 20:35
Wordpress - Functions: Create Child Theme path
// Creates directory path to child theme - functions.php
function get_childTheme_url() {
return dirname( get_bloginfo('stylesheet_url') );
}
// Prints path
<?php echo get_childTheme_url(); ?>
@barbwiredmedia
barbwiredmedia / jQuery & Bootstrap: Switch and Scroll to a tab
Created August 26, 2013 17:47
jQuery - Twitter Bootstrap's Tab piece. This allows hotlinking to the tab (opens page, and opens tab specified in the url) as well as changes url on tab change. (Should keep the nav-tabs class the same.)
<script>
$(function(){
var hash = window.location.hash;
hash && $('ul.nav a[href="' + hash + '"]').tab('show');
$('.nav-tabs a').click(function (e) {
$(this).tab('show');
var scrollmem = $('body').scrollTop();
window.location.hash = this.hash;
$('html,body').scrollTop(scrollmem);
@barbwiredmedia
barbwiredmedia / Wordpress - Templates: Display RSS Feed
Created August 26, 2013 20:35
Wordpress - Templates: Display Any RSS Feed on Your WordPress Blog
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('http://mattsmithpt.wordpress.com/feed/');
$maxitems = $rss->get_item_quantity(5);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php
if ($maxitems == 0)
echo '<li>No news stories.</li>';
@barbwiredmedia
barbwiredmedia / Wordpress - wp-config
Last active December 22, 2015 11:48
When deploying a site from a development server just add this into wp-config to change the siteurl and home url. Will change where Wordpress looks for the build. Define site url. define site
define('WP_SITEURL', 'http://www.yournewurl.com');
define('WP_HOME', 'http://www.yournewurl.com');