This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* replace WordPress Howdy | |
*/ | |
function goodbye_howdy($links) | |
{ | |
$links = str_replace( 'Howdy', 'Hello', $links ); | |
return $links; | |
} | |
add_filter( 'admin_user_info_links', 'goodbye_howdy' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ADD CAPABILITIES FOR EDITOR ROLE | |
function update_capabilities() { | |
$role = get_role( 'editor' ); | |
$caps_to_add = array( | |
'manage_options' | |
); | |
foreach( $caps_to_add as $cap ) | |
$role->add_cap( $cap ); | |
} | |
function remove_menu_pages() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('pre_get_posts', 'query_post_type'); | |
function query_post_type($query) { | |
if(is_category() || is_tag()) { | |
$post_type = get_query_var('post_type'); | |
if($post_type) | |
$post_type = $post_type; | |
else | |
$post_type = array('post','cpt'); // replace cpt to your custom post type | |
$query->set('post_type',$post_type); | |
return $query; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Put in functions.php | |
/* GET TOTAL NUMBER OF POSTS FOR SPECIFIC CUSTOM POST TYPE */ | |
function cpt_count($ptype,$display=true) { | |
global $wpdb; | |
$SQL = "SELECT count(*) FROM $wpdb->posts posts WHERE posts.post_status = 'publish' AND post_type = '".$ptype."' "; | |
$total_cpt_posts = $wpdb->get_var($SQL); | |
if($display) { | |
echo $total_cpt_posts; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* GET CURRENT PAGE NUMBER FOR THIS SINGLE POST ie. it's index number */ | |
// put in functions.php | |
// Note: edit "my-custom-post-type" or remove "AND post_type = 'my-custom-post-type'" | |
function current_post_num($display=true) { | |
global $post, $wpdb; | |
//$rows = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date ASC"); | |
$SQL = $wpdb->get_col("SELECT ID FROM $wpdb->posts posts WHERE posts.post_status = 'publish' AND post_type = 'my-custom-post-type' ORDER BY post_date ASC"); | |
$SQL = array_flip($SQL); | |
$postnum = $SQL[$post->ID]; | |
$postnum++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Usual method, not in a list: | |
<?php | |
while (have_posts()) : the_post(); | |
the_tags('','',''); | |
endwhile; | |
?> | |
//Use wp_list_categories for UL: | |
<?php | |
wp_list_categories( array('taxonomy' => 'post_tag', 'title_li' => '', 'orderby' => 'name', 'order' => 'ASC') ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP if statements around html blocks | |
<?php if ( x==y ) : ?> | |
<div> | |
Your html | |
</div> | |
<?php else : ?> | |
<div> | |
Your alternative html | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CROSS-BROWSER TRANSITION END EVENT LISTENERS | |
var transEndEventNames = { | |
'WebkitTransition' : 'webkitTransitionEnd', | |
'MozTransition' : 'transitionend', | |
'OTransition' : 'oTransitionEnd', | |
'msTransition' : 'MSTransitionEnd', | |
'transition' : 'transitionend' | |
}, | |
transEndEventName = transEndEventNames[ Modernizr.prefixed('transition') ]; // bind event listener to transEndEventName eg: this.addEventListener(transEndEventName, callbackFunction, false); | |
//alert(transEndEventName); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_tag_id_by_name($tag_name) { | |
global $wpdb; | |
$tag_ID = $wpdb->get_var("SELECT * FROM ".$wpdb->terms." WHERE `name` = '".$tag_name."'"); | |
return $tag_ID; | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function twitterify($ret) { | |
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); | |
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret); | |
$ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $ret); | |
$ret = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $ret); | |
return $ret; | |
} | |
#Thanks: http://www.snipe.net/2009/09/php-twitter-clickable-links/ |
OlderNewer