hide certain wordpress pages or posts from search

Some time you don’t want to come the some page and posts come in search. Here is very simple technique for excluding or removing the some wordpess pages or posts from wordpress search.

hide certain wordpress pages or posts from search

You just need to put following code in functions.php file. You will find this file in your wordpress theme folder. To work this idea you need to know about the page or post id which you want to exclude from search.

When you are creating the post that time you can get the wordpress post id Or while editing the post you will know the wordpress post or page id.


// search filter
function my_search_filter($query) {
 // make sure we are not in the admin and that we are performing a search
 if ( !$query->is_admin && $query->is_search) {
 $query->set('post__not_in', array(50, 10,32,68) ); // IDs of pages or posts
 }
 return $query;
}
add_filter( 'pre_get_posts', 'my_search_filter' );

hide certain wordpress pages or posts from search
hide certain wordpress pages or posts from search

Add different Editor Styles for Custom Post Types in WordPress

There is custom post type support added from wordpress 2.9 in wordpress. Many times we create the different types of post type in wordpress and show it i different way. We use the different styles for showing the content types..

Add different Editor Styles for Custom Post Types in WordPress

Add different Editor Styles for Custom Post Types in WordPress
Add different Editor Styles for Custom Post Types in WordPress

In wordpress we have the visual and html editor. For adding the different styles for custom post types just open your functions.php file put the following code in that file.


function my_editor_style() {
 global $current_screen;
 switch ($current_screen->post_type) {
 case 'post':
 add_editor_style('editor-style-post.css');
 break;
 case 'page':
 add_editor_style('editor-style-page.css');
 break;
 case 'product':
 add_editor_style('editor-style-product.css');
 break;
case 'shop':
 add_editor_style('editor-style-shop.css');
 break;

}
}
add_action( 'admin_head', 'my_editor_style' );

If you are not wordpress developer then dont use above code. In purabtech.in site you will find many wordpress tutorials and tips and hacks and plugins. Please write to me on support@purabtech.in

how to add buttons to wordpress wysiwyg editor

You can add buttons to wordpress wysiwyg editor using following code. For changing wordpress wysiwyg editor, we need to use the quick_tags.js file using hook.

how to add buttons to wordpress wysiwyg editor

But from wordpress 3.1 version we can customize the wordpress editor by using wordpress filter.

Adding more buttons to the editor is really easy. Simply paste this snippet into your theme’s functions.php file.

function enable_more_buttons($buttons) {
 $buttons[] = 'hr';
 $buttons[] = 'sub';
 $buttons[] = 'sup';
 $buttons[] = 'fontselect';
 $buttons[] = 'fontsizeselect';
 $buttons[] = 'cleanup';
 $buttons[] = 'styleselect';
 return $buttons;
}
add_filter("mce_buttons_3", "enable_more_buttons");
how to add buttons to wordpress wysiwyg editor
how to add buttons to wordpress wysiwyg editor

Note: If you are not wordpress developer then do not use above code. Ask your developers to do this for you.

Send email to site users about new wordpress posts

For increasing traffic of website. It is good to send email to users about new post. we have script for Send email to site users about new wordpress posts.

There are many wordpress plugins available for sending email but I given small code for sending email to wordpress users without using any wordpress plugins

Send email to site users about new wordpress posts
Send email to site users about new wordpress posts

If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file. Just copy and paste the following code on your functions.php file:

function send_email_users($post_ID)  {
    global $wpdb;
    $usersarray = $wpdb->get_results("SELECT user_email FROM $wpdb->users;");
    $users = implode(",", $usersarray);
    mail($users, "New Article is Published", 'A new article have been published on http://www.purabtech.in. Please visit');
    return $post_ID;
}
add_action('publish_post', 'send_email_users');

You just need to change my domain name to your domain name and put that in your functions.php file. If you are having any issues then Please write to me.
This wordpress hack, tip or trick written by wordpressapi.

Here is some very useful links for wordpress.

Check Following articles for great wordpress hacks of the all the time.

how to create contact us page without wordpress plugin
Add the extra new users details or fields to wordpress without plugin
Display wordpress Tags In A Dropdown Menu without plugin
How to change the Visual Editor Font Size wordpress without plugin
Display wordpress Tags In A Dropdown Menu without plugin
wordpress pagination style without wordpress plugin
show popular posts without wordpress plugin in theme
How to send smtp email through wordpress without plugin
How to put digg button in wordpress without plugin
Get the recent comments without using wordpress plugin or widget
How to Add the social Bookmar Icons in WordPress theme without wordpress plugins
How to exclude pages from wordpress menu without plugin
Show related posts with wordpress post without using any plugin

Share buttons in wordpress without wordpress plugin

I don’t recommend you to use wordpress plugin for adding the share buttons. we have simple code for add Share buttons in wordpress without wordpress plugin

Share buttons in wordpress without wordpress plugin

There are many wordpress plugins available for adding share button in wordpress or any website. I don’t recommend you to use the wordpress plugin for adding the share buttons like, facebook, twitter, linkedin, stumbleupon, delicious and Google buzz. Because when you install wordpress plugin for social buttons then that plugin will use your database and on every page view that will fire query to your database and your page view will became little bit slower. If you are having less visitors then this ok but if your site is having large visitors than you need to think about small issues also. Floating share button are very popular these days. You can easily add the sharebox which floating bar. Using following code you can add the share buttons without wordpress plugin.

I written some code for this and on my site share buttons are looking as follows:

Share buttons in wordpress without wordpress plugin
Share buttons in wordpress without wordpress plugin

I created file called sharebox.php and in that file just written following code.

<div id="sharebox" style="">
<a href="http://twitter.com/share" data-count="vertical" data-via="digcms">
Tweet</a>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js">
</script>
</div>
<div>
<script>var fbShare = {url: <?php the_permalink() ?>,size: 'large',badge_text: 'fff',badge_color: '3b5998',google_analytics: 'true'}</script>
<script src="http://widgets.fbshare.me/files/fbshare.js"></script>
</div><div>
<script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script>
</div>
<div><a class='delicious-button'  href='http://delicious.com/save'> <!-- { url:"<?php the_permalink() ?>" ,title:"<?php the_title() ?>" } --> Save on Delicious</a></div><div style="display:none;">

<script type="text/javascript">(function() {var s = document.createElement('SCRIPT'), s1 = document.getElementsByTagName('SCRIPT')[0];s.type = 'text/javascript';s.async = true;s.src = 'http://widgets.digg.com/buttons.js';s1.parentNode.insertBefore(s, s1);})();</script><a></a>

</div>

<div><a title="Post on Google Buzz" href="http://www.google.com/buzz/post" data-button-style="normal-count"></a>
<script type="text/javascript" src="http://www.google.com/buzz/api/button.js"></script>

</div><div><script type="text/javascript" src="http://platform.linkedin.com/in.js"></script>
<script type="in/share" data-counter="top"></script></div></div>

After creating sharebox.php file, open your single.php file and put following code in that file.

<?php include 'sharebox.php'; ?>

After that open your style.css file and put following code in that file.

#sharebox{display: block;margin-left: -85px;
position: fixed;top:105px;width:65px;
border:#ccc 1px solid;padding:2px}

If you need more buttons then you should prefer following article. In this article you will find the all the share button code. and you dont need to add any wordpress plugin for adding share or like buttons in wordpress site.

Please write comment for our article: Share buttons in wordpress without wordpress plugin

Add the social Bookmark Icons in WordPress theme without plugins

How to hide wordpress visual editor and HTML editor

If you want to hide the wordpress editor from admin panel then you can use the following code in functions.php file. This is achieved with very simple css trick. You just need to add the following hook into your functions.php file which you can find in your wordpress theme folder.

you can do this in two ways. First with using admin panel.  First thing you need to do is login to your WordPress admin panel.

Then you would need to go to Users > Your Profile,

Just disable visual editor checkbox. That sit. But if you want to this setting to done for all wordpress users then you can use following code.

How to hide wordpress visual editor and HTML editor

How to hide wordpress visual editor and HTML editor
How to hide wordpress visual editor and HTML editor

you just need add following code into your functions.php file. This file you can find in your wordpress theme folder.

 

add_action('admin_head', 'hide_post_box');

function hide_post_box() {
?>
<%%KEEPWHITESPACE%%> <style>
<%%KEEPWHITESPACE%%> #editor-toolbar{ display:none; }
<%%KEEPWHITESPACE%%> #editorcontainer{ display:none; }
<%%KEEPWHITESPACE%%> #quicktags { display:none; }
<%%KEEPWHITESPACE%%> #post-status-info { display:none; }
<%%KEEPWHITESPACE%%> </style>
<?php
}

change Visual Editor Font Size without wordpress plugin

wordpress tutorial for, change Visual Editor Font Size without wordpress plugin. need to open your functions.php file and put following code in that file.

change Visual Editor Font Size without wordpress plugin

change Visual Editor Font Size without wordpress plugin
change Visual Editor Font Size without wordpress plugin

You need to open your functions.php file and put following code in that file.using following code you can change the font size of editor.

Note: If you are not having knowledge of wordpress code and php then dont use  the code.

add_action( ‘admin_print_styles-post.php’, ‘my_admin_css’ ); add_action( ‘admin_print_styles-post-new.php’, ‘my_admin_css’ ); function my_admin_css() { ?&gt; &lt;style type=”text/css”&gt; #editorcontainer textarea#content { font-size: 2em !important } &lt;/style&gt; &lt;?php

 

wordpress visual editor keyboard shortcuts for bloggers

Tips for Bloggers, wordpress visual editor keyboard shortcuts for bloggers, In wordpress admin panel and with new post option we can use keyboard shortcuts also.

wordpress visual editor keyboard shortcuts for bloggers

Here is list of keyboard shortcuts for wordpress editor for admin panel. wordpress shortcuts are available from wordpress 2.6 version and that is still there. But in current versions of wordpress you cannot see the hotlinks but you can use that for fast blogging.

  • Alt+Shift+A : Hyperlink Selected Text.
  • Alt+Shift+T : Add read more Tag to post.
  • Ctrl+[Header Number] : Used to apply header tag to current line.
  • Alt+Shift+L/R/C : Align Left/ Right / Center.
  • Alt+Shift+S : Justify Text.
  • Alt+Shift+D : Strike through Text.
  • Alt+Shift+U : Start unordered list
  • Alt+Shift+O : Start an ordered list.
  • Alt+Shift+P : Add a new page to your post.
  • Alt+Shift+Q : Enter a blockquote.
  • Alt+Shift+H : Toggle Full Screen.

The visual editor has several keyboard shortcuts, or hotkeys, built in.

wordpress visual editor keyboard shortcuts for bloggers
wordpress visual editor keyboard shortcuts for bloggers

enable comments for custom post type

In wordpress we can create the custom post types. Now everybody is using custom post types in wordpress and need comments functionality for custom post types also. Custom post types are very important feature of wordpress. For enabling the comments for custom post type just use the following line.

enable comments for custom post type

'supports' => array('title','editor','author','thumbnail','excerpt','comments')

Following line will add the title, thumbnail, excerpt and comments functionality to your custom post type.

enable comments for custom post type
enable comments for custom post type

For more information use check my following code. I used following code in my functions.php file.

add_action('init', 'wordpress_themes');
 function wordpress_themes() {
 $wp_themes_args = array(
 'label' => __('Wordpress Themes'),
 'singular_label' => __('Wordpress Themes'),
 'public' => true,
 'show_ui' => true,
 'capability_type' => 'post',
 'hierarchical' => false,
 'rewrite' => true,
  'supports' => array('title','editor','author','thumbnail','excerpt','comments'),
           'taxonomies' => array('category', 'post_tag') // this is IMPORTANT

 );
 register_post_type('wordpress-themes',$wp_themes_args);
 }

disable html code in comments wordpress

WordPress tutorial for, disable html code in comments wordpress. We given code sample for functions file to prevent html code in wordpress comments section.

If you are wordpress developer then only use following code. Open your functions.php file from your theme and put following code in that file. Just copy and paste the following code on your functions.php file:

disable html code in comments wordpress

function wordpress_comment_post( $incoming_comment ) {
	$incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
	$incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] );
	return( $incoming_comment );
}

function wordpress_comment_display( $comment_to_display ) {
	$comment_to_display = str_replace( '&apos;', "'", $comment_to_display );
	return $comment_to_display;
}
add_filter( 'preprocess_comment', 'wordpress_comment_post', '', 1);
add_filter( 'comment_text', 'wordpress_comment_display', '', 1);
add_filter( 'comment_text_rss', 'wordpress_comment_display', '', 1);
add_filter( 'comment_excerpt', 'wordpress_comment_display', '', 1);
disable html code in comments wordpress
disable html code in comments wordpress