Created
June 7, 2012 20:08
-
-
Save reinislejnieks/2891269 to your computer and use it in GitHub Desktop.
useful WP things
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 | |
wp_enqueue_script('jquery'); /*in header.php before wp_head();*/ | |
/*--------------------------------*/ | |
/* for wp */ | |
wp_deregister_script('jquery'); | |
wp_register_script('jquery',("http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"),false,'1.6.2'); | |
wp_enqueue_script('jquery'); | |
/*--------------------------------*/ | |
bloginfo('template_directory'); | |
/*--------------------------------*/ | |
if(): | |
else if(): | |
else: | |
endif; | |
/*--------------------------------*/ | |
echo $var = get_the_title($post->post_parent);/*get parent page title*/ | |
/*--------------------------------*/ | |
echo $post->ID;/*get page ID*/ | |
/*--------------------------------*/ | |
include (TEMPLATEPATH . '/altheader.php'); | |
/*--------------------------------*/ | |
the_date('y-m-d','<p>','</p>'); | |
/*--------------------------------*/ | |
is_sticky(); is_home(); | |
/*--------------------------------*/ | |
//to do stuff outside of the main loop | |
$my_new_query = new WP_Query(); | |
//and then | |
if($my_new_query->have_posts()){ | |
while($my_new_query->have_posts()){ | |
$my_new_query->the_post(); | |
} | |
} | |
/*--------------------------------*/ | |
/* Template Name: My Page Template */ | |
/*--------------------------------*/ | |
add_action('action_hook','your_function'); | |
/*--------------------------------*/ | |
// CUSTOM ADMIN LOGIN HEADER LOGO | |
function my_custom_login_logo() { | |
echo '<style type="text/css"> h1 a { background-image:url('.get_bloginfo('template_directory').'/images/logo_admin.png) !important; } </style>'; | |
} | |
add_action('login_head', 'my_custom_login_logo'); | |
/*--------------------------------*/ | |
// Manually add sharebuttons | |
add_filter( 'the_content', 'ilc_share' ); | |
function ilc_share( $content ) { | |
global $post; | |
$postlink = get_permalink($post->ID); | |
$posttitle = get_the_title($post->ID); | |
$html = '<ul class="share-entry">'; | |
$html .= '<li><a class="share-twitter" title="Share on Twitter" rel="external" href="http://twitter.com/share?text='.$posttitle.'&url='.$postlink.'">Share on Twitter</a></li>'; | |
$html .= '<li><a class="share-facebook" title="Share on Facebook" rel="external" href="http://www.facebook.com/share.php?u=' . $postlink . '">Share on Facebook</a></li>'; | |
$html .= '<li><a class="share-linkedin" title="Share on LinkedIn" rel="external" href="http://www.linkedin.com/shareArticle?mini=true&url=' . $postlink . '&title=' . $posttitle . '">Share on LinkedIn</a></li>'; | |
// Digg | |
$html .= '<li><a class="share-digg" title="Share on Digg" rel="external" href="http://digg.com/submit?url=' . $postlink . '">Share on Digg</a></li>'; | |
// StumbleUpon | |
$html .= '<li><a class="share-stumbleupon" title="Share on StumbleUpon" rel="external" href="http://www.stumbleupon.com/submit?url=' . $postlink . '&title=' . $posttitle . '">Share on StumbleUpon</a></li>'; | |
// Google+ | |
$html .= '<li><a class="share-googleplus" title="Share on Google+" rel="external" href="https://plusone.google.com/_/+1/confirm?url=' . $postlink . '">Share on Google+</a></li>'; | |
$html .= '</ul>'; | |
return $content . $html; | |
} | |
/*--------------------------------*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment