Skip to content

Instantly share code, notes, and snippets.

@xafarali
xafarali / custom_menu_item.php
Created June 10, 2013 02:28
Custom Menu Items
add_filter( 'wp_nav_menu_items', 'custom_menu_item', 10, 2 );
function custom_menu_item ( $items, $args ) {
if ($args->theme_location == 'primary') {
$items .= '<li>This is Custom Menu</li>';
}
return $items;
}
// custom first and last class
@xafarali
xafarali / admin_style.php
Created June 9, 2013 23:39
Custom Style sheet for admin Panel
/*----------- Print Stylesheet -------------*/
/* =====================================
Print Stylesheet and script from
my theme folder to Admin Panel
=======================================*/
add_action("admin_init", "custom_post_assets");
function custom_post_assets() {
global $post_type;
@xafarali
xafarali / custom_login.php
Created June 9, 2013 23:37
Customize Login Screen
/* ===============================================
--------- Custom Login Screen --------------
================================================== */
add_action("login_head", "sepiaLogin");
function sepiaLogin() {
project_admin_css();
}
@xafarali
xafarali / custom_post_in_loop.php
Created June 9, 2013 22:42
Add Custom Post In Master Loop
<?php
if (is_archive() || is_category() || is_search() ) {
global $query_string;
parse_str( $query_string, $args );
$args['post_type'] = array( 'ss-video', 'post' );
query_posts( $args );
}
?>
@xafarali
xafarali / register Post type.php
Created June 9, 2013 22:28
Register Post Type
///////////////////////////////////
// Custom Post Type , Video
///////////////////////////////////
// Custom Post - Project
function create_banner() {
// label for post type project.
@xafarali
xafarali / post_post_thumb.php
Created June 9, 2013 22:19
Post Thumbnail in Loop
<?php if ( has_post_thumbnail()) : ?>
<span class="post-thumb">
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail('thumbnail'); ?></a>
</span>
<?php endif; ?>
@xafarali
xafarali / add_thbnail_sizes.php
Created June 9, 2013 22:11
Add Thumbnail Sizes
/* FEATURED THUMBNAILS */
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
add_theme_support( 'post-thumbnails' );
}
add_image_size('small-thumbnail', 80, 80, true);
/* ===============================================
@xafarali
xafarali / add_recent_post_shortcode.php
Created June 9, 2013 22:04
Add Recent Post shortcode
// Shortcode for recent post
add_shortcode('ss_recentpost','ss_recent_post');
// add_filter('the_content', 'do_shortcode', 11);
add_filter('widget_text', 'do_shortcode');
function ss_recent_post($attr) {
@xafarali
xafarali / get_thumbnail_url.php
Created June 9, 2013 22:01
Get Thumbnail URL
/* GET THUMBNAIL URL */
function get_image_url(){
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'large');
$image_url = $image_url[0];
echo $image_url;
}
@xafarali
xafarali / register_que_deque.php
Created June 9, 2013 21:44
Register , Enqueue & Dequeue Scripts and Styles
// Enqueue Styles
function load_styles() {
wp_enqueue_style('AD-Gallery', $this->plugin_url . 'css/ad-gallery.css', false, '', 'screen');
wp_enqueue_style('jScrollPane', $this->plugin_url . 'css/jScrollPane.css', false, '', 'screen');
}
// Enqueue Scripts
function load_scripts() {