Skip to content

Instantly share code, notes, and snippets.

// Register a new custom post type named Books;
register_post_type('books', array(
'public' => true,
'menu_icon' => 'dashicons-book',
'label' => __( 'Books', 'local' ),
)
);
@vijujohns
vijujohns / dashicon-include.html
Created July 25, 2015 19:13
Include dashicon
<i class="dashicons dashicons-wordpress"></i>
@vijujohns
vijujohns / 125x125 Ads.html
Last active August 29, 2015 14:26
Include responsive 125x125 Ad space in your WordPress blog sidebar without any plugin - http://www.wppicker.com/create-125x125-ad-space-site-sidebar-using-text-widgets/
<div style="float:right;position:relative;left:-50%;text-align:center;">
<div style="position:relative;left:50%;">
<!--125x125 Ad Banner Block#1-->
<a href="http://www.google.com" target=_blank>
<img src="http://localhost/wp-content/uploads/2015/07/a.png" alt="Google Banner" width="125" height="125" rel="nofollow" />
</a>
<!--125x125 Ad Banner Block#2-->
<a href="http://yahoo.com" target=_blank>
<div style="float:right;position:relative;left:-50%;text-align:center;">
<div style="position:relative;left:50%;">
<!--125x125 Ad Banner#1-->
<a href="target link here" target=_blank>
<img src="File URL of ad banner image here" alt="alt txt for ad 1" width="125" height="125" rel="nofollow" />
</a>
<!--125x125 Ad Banner#2-->
<a href="target link here" target=_blank>
//Automatically Insert Google Adsense ads to the top left or right of each post content.
add_filter( 'the_content', 'wpp_insert_ads_to_content' );
function wpp_insert_ads_to_content( $content ) {
$ad_code_wrapper_start = '<div style=”display:block;float:right;margin: 0px 0px 0px 10px;”>';
$ad_code = ' Copy and Paste Ad sense code here. Do not remove the starting and ending single quotes ';
$ad_code_wrapper_end = '</div>';
@vijujohns
vijujohns / site-plugin.php
Last active August 29, 2015 14:26
Create a site specific plugin to host your local functions that can be enabled or disabled any time. http://www.wppicker.com/why-and-how-should-i-use-a-site-specific-plugin-for-wordpress/
<?php
/*
Plugin Name: Site Plugin for mysite.com
Version: 1.0
Author: Your Name
Description: Custom functions for mysite.com
*/
/* Start Adding Functions Below this Line */
/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/
Description: Child theme for the Twenty Fifteen theme
Author: Your name here
Author URI: http://example.com/about/
Template: twentyfifteen
Version: 0.1.0
*/
/*Include a file from Child Theme Directory*/
<?php require_once( get_stylesheet_directory(). '/functions/child_theme_include_file.php' ); ?>
/*Include a file from Parent Theme Directory*/
<?php require_once( get_template_directory(). '/functions/parent_theme_include_file.php' ); ?>
/*Include a image from Child Theme Directory*/
<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/my_picture.png" alt="" />
//* Remove Comment Form Website URL Field
add_filter('comment_form_default_fields','wpp_remove_comment_url');
function wpp_remove_comment_url($fields) {
unset($fields['url']);
return $fields;
}
//* Remove comment form allowed tags
add_filter( 'comment_form_defaults', 'wpp_remove_comment_form_allowed_tags' );
function wpp_remove_comment_form_allowed_tags( $defaults ) {
@vijujohns
vijujohns / remove-version.php
Last active August 29, 2015 14:27
code to remove wordpress version from head tags of pages, rss feeds etc http://www.wppicker.com/wordpress-security-remove-version-number-from-meta-generator-rss/
/*remove wordpress version number from front-end pages*/
function remove_version_from_mysite() {
return '';
}
add_filter('the_generator','remove_version_from_mysite');