Skip to content

Instantly share code, notes, and snippets.

@ellenmva
ellenmva / tabtastic-bold.css
Last active August 29, 2015 13:56
Tab Titles Bold in Tabtastic
/* Add to Custom LESS/CSS Box in Custom Tab DMS */
/* FullTabs Tab Title Bold */
.section-fulltabs .nav a {
font-weight: bold;
}
/* QuickTabs Tab Title Bold */
@ellenmva
ellenmva / p-tags-text.php
Created December 7, 2013 11:56
Add paragraph tags to text
$my_text = 'Lorem ipsum dolor sit amet
consectetur adipiscing elit.
Nulla pretium libero eget gravida rutrum.';
echo wpautop( $my_text );
@ellenmva
ellenmva / category-current-tags.php
Created December 5, 2013 22:50
Get tags for current category only
query_posts('category_name=work');
if (have_posts()) : while (have_posts()) : the_post();
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$all_tags_arr[] = $tag -> name; //USING JUST $tag MAKING $all_tags_arr A MULTI-DIMENSIONAL ARRAY, WHICH DOES WORK WITH array_unique
}
}
endwhile; endif;
@ellenmva
ellenmva / user-posts.php
Created November 25, 2013 19:48
if a certain page, then display posts authored by the logged in user
<?php
//if a certain page, then display posts authored by the logged in user
$page_title = 'Contributors Page';
if ( is_user_logged_in() && is_page($page_title) ) {
global $current_user;
get_currentuserinfo();
echo 'User ID: ' . $current_user->ID . "\n";
$args=array(
'author' => $current_user->ID,
'post_type' => 'post',
@ellenmva
ellenmva / crop-images.css
Created November 23, 2013 14:27
Filtering: crop images
.section-filtering .filtering-image {
overflow: hidden; /* Crops the image */
}
.section-filtering .filtering-image img {
max-width: 100% !important; /* Overrides max width */
max-height: none !important; /* Overrides max height */
width: 250px; /* Width of image */
}
@ellenmva
ellenmva / special_nav_class.php
Created November 15, 2013 13:39
Add class to menu item for single post or post type to display as current
//Filtering a Class in Navigation Menu Item
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
if(is_singular('post') && $item->title == 'Menu Item'){
$classes[] = 'current-menu-item';
}
if(is_singular('post_type') && $item->title == 'Menu_Item'){
$classes[] = 'current-menu-item';
}
return $classes;
@ellenmva
ellenmva / acf-check.php
Created November 7, 2013 21:43
check for acf
global $acf;
if( !$acf )
{
define( 'ACF_LITE' , true );
include_once('advanced-custom-fields/acf.php' );
}
@ellenmva
ellenmva / custom-fields-shortcode.php
Created November 7, 2013 13:10
Execute Shortcodes inside custom fields
<?php echo apply_filters('the_content', get_post_meta($post->ID, 'your_custom_field_here', true)); ?>
@ellenmva
ellenmva / template-chooser
Created November 6, 2013 13:59
Nick's template chooser
add_filter( 'template_include', array($this,'template_chooser'));
function template_chooser( $template ) {
// Post ID
$post_id = get_the_ID();
// For all other CPT
if ( get_post_type( $post_id ) != 'projects' ) {
return $template;
}
@ellenmva
ellenmva / acf-translate.php
Created November 4, 2013 22:28
Translate ACF Fields
function acf_translate_fields( $field ){
$field['label' ] = __( $field['label' ], 'plugin-slug' );
$field['instructions' ] = __( $field['instructions' ], 'plugin-slug' );
return $field;
}
add_filter('acf/load_field', array($this,'acf_translate_fields'));