add custom fields to user profile wordpress without plugin

WordPress tutorial, add custom fields to user profile wordpress without plugin. For adding extra details use can use following sample code in functions.php file. You can modify the code as per your requirement.

add custom fields to user profile wordpress without plugin

add custom fields to user profile wordpress without plugin
add custom fields to user profile wordpress without plugin

Note: If you are not wordpress developer then you should ask any wordpress developer to do this changes.

add_action( 'show_user_profile', 'extra_fields_to_user' );
add_action( 'edit_user_profile', 'extra_fields_to_user' );

function extra_fields_to_user( $user ) { ?>

 <h3>Extra profile information</h3>

 <table>

 <tr>
 <th><label for="facebook">facebook</label></th>

 <td>
 <input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" /><br />
 <span>Please enter your facebook username.</span>
 </td>
 </tr>

 </table>
<?php }
add_action( 'personal_options_update', 'extra_fields_to_user_save' );
add_action( 'edit_user_profile_update', 'extra_fields_to_user_save' );

function extra_fields_to_user_save( $user_id ) {

 if ( !current_user_can( 'edit_user', $user_id ) )
 return false;

 /* Copy and paste this line for additional fields. Make sure to change 'facebook' to the field ID. */
 update_usermeta( $user_id, 'facebook', $_POST['facebook'] );
}

showing the user information use following code.
<?php the_author_meta( ‘facebook’ ); ?>

how to display wordpress categories in a drop down menu

wordpress tutorial, how to display wordpress categories in a drop down menu. For showing the categories in drop down menu just use our following code.

how to display wordpress categories in a drop down menu

You just need to copy paste following code in put in functions.php file.


<li id="categories"><h2><?php _e('Posts by Category'); ?></h2>
 <?php wp_dropdown_categories('show_option_none=Select category'); ?>

<script type="text/javascript"><!--
 var dropdown = document.getElementById("cat");
 function onCatChange() {
 if ( dropdown.options[dropdown.selectedIndex].value > 0 ) {
 location.href = "<?php echo get_option('home');
?>/?cat="+dropdown.options[dropdown.selectedIndex].value;
 }
 }
 dropdown.onchange = onCatChange;
--></script>
</li>

For more information you can use the following code.

how to display wordpress categories in a drop down menu
how to display wordpress categories in a drop down menu

Display wordpress Tags In Dropdown Menu without plugin

WordPress tutorial, Display wordpress Tags In Dropdown Menu without plugin. we given simple code here which you need to put in theme functions.php file.

If you want to display the tags in drop down menu then use following code in functions.php file.

Display wordpress Tags In Dropdown Menu without plugin


<?php
function dropdown_tag_cloud( $args = '' ) {
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC',
'exclude' => '', 'include' => ''
);
$args = wp_parse_args( $args, $defaults );

$tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags

if ( empty($tags) )
return;

$return = dropdown_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
if ( is_wp_error( $return ) )
return false;
else
echo apply_filters( 'dropdown_tag_cloud', $return, $args );
}

function dropdown_generate_tag_cloud( $tags, $args = '' ) {
global $wp_rewrite;
$defaults = array(
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC'
);
$args = wp_parse_args( $args, $defaults );
extract($args);

if ( !$tags )
return;
$counts = $tag_links = array();
foreach ( (array) $tags as $tag ) {
$counts[$tag->name] = $tag->count;
$tag_links[$tag->name] = get_tag_link( $tag->term_id );
if ( is_wp_error( $tag_links[$tag->name] ) )
return $tag_links[$tag->name];
$tag_ids[$tag->name] = $tag->term_id;
}

$min_count = min($counts);
$spread = max($counts) - $min_count;
if ( $spread <= 0 )
$spread = 1;
$font_spread = $largest - $smallest;
if ( $font_spread <= 0 )
$font_spread = 1;
$font_step = $font_spread / $spread;

// SQL cannot save you; this is a second (potentially different) sort on a subset of data.
if ( 'name' == $orderby )
uksort($counts, 'strnatcasecmp');
else
asort($counts);

if ( 'DESC' == $order )
$counts = array_reverse( $counts, true );

$a = array();

$rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : '';

foreach ( $counts as $tag => $count ) {
$tag_id = $tag_ids[$tag];
$tag_link = clean_url($tag_links[$tag]);
$tag = str_replace(' ', ' ', wp_specialchars( $tag ));
$a[] = "\t<option value='$tag_link'>$tag ($count)</option>";
}

switch ( $format ) :
case 'array' :
$return =& $a;
break;
case 'list' :
$return = "<ul class='wp-tag-cloud'>\n\t<li>";
$return .= join("</li>\n\t<li>", $a);
$return .= "</li>\n</ul>\n";
break;
default :
$return = join("\n", $a);
break;
endswitch;

return apply_filters( 'dropdown_generate_tag_cloud', $return, $tags, $args );
}
?>

In footer or sidebar file or where you want to display the tags in dropdown use the following code.

Display wordpress Tags In Dropdown Menu without plugin
Display wordpress Tags In Dropdown Menu without plugin

<select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="#">Liste d'auteurs</option>
<?php dropdown_tag_cloud('number=0&order=asc'); ?>
</select>

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
}

how to display your posts words count in wordpress

WordPress tutorial, how to display your posts words count in wordpress. Here in this article we given code for adding in your theme functions.php file.

how to display your posts words count in wordpress

 

how to display your posts words count in wordpress
how to display your posts words count in wordpress

If you want to display the words count in your post. you should use the following code in functions.php file.

If you are not wordpress developer then dont use this code in your theme files.

function wcount(){
 ob_start();
 the_content();
 $content = ob_get_clean();
 return sizeof(explode(" ", $content));
}

 

In single.php file put following code for showing the word count.


echo wcount();

 

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

 

how to show author in wordpress post

wordpress tutorial, how to show author in wordpress post. Many people want to read the author information after the article. This is good for seo also.

how to show author in wordpress post

You can show the author information in single page using following code. just open your single.php file and put following code after the  the_content() function.

<div id="author-information">
<div id="author-image">
 <a href="<?php the_author_meta('user_url'); ?>">
 <?php echo get_avatar( get_the_author_meta('user_email'), '150',
 '' ); ?></a></div>
<div id="author-bio">
<h4>Written by < ?php the_author_link(); ?></h4>

< ?php the_author_meta('description'); ?>
</div>
</div>
<!--Author information-->

Use following code in your css file

#author-information{float:left;width:auto;clear:both;}
#author-image{border:3px solid #CCC; float:left:width:160px;}
#author-bio{padding:5px;float:left;}
how to show author in wordpress post
how to show author in wordpress post

Useful mysql queries for wordpress migration

For developers wordpress moving site to new server is daily job. wp migration is easy with mysql query. Here is useful mysql queries for wordpress migration. This mysql query are very useful for moving wordpress data to new server.

Note: before executing following queries, first take backup of wordpress database first. it is very important for safety and backup purpose. I recommend, always take database backup while doing any database operation. Taking database backup is good practice.

When you want to change your domain name for wordpress site. You need to first take backup of your file system and mysql database. Make sure that backup is completely taken. Verify with any wordpress developer. Then only you start the migration. For wordpress domain migration following mysql queries are required.

mysql queries for wordpress migration

I already written detail article for this. You should read following article.

https://purabtech.in/wordpress-migration-hosting-service-domain/

Here is list of mysql queries which are very important when you are doing the wordpress site migration.

UPDATE wp_options SET option_value = REPLACE(option_value, 'oldsite.com', 'newsite.com');
UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, 'oldsite.com', 'newsite.com');
UPDATE wp_posts SET post_content = REPLACE(post_content, 'oldsite.com', 'newsite.com');
UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, 'oldsite.com', 'newsite.com');
UPDATE wp_posts SET guid = REPLACE(guid, 'oldsite.com', 'newsite.com');
mysql queries for wordpress migration
mysql queries for wordpress migration

checklist for self hosted wordpress sites

When you creating site in wordpress, I created unique checklist for self hosted wordpress sites. checklist for self hosted wordpress sites is very important.

checklist for self hosted wordpress sites

When you creating the website in wordpress that time you need to be very careful and you need think and check about following things. I created the checklist for wordpress sites.

About Theme

Use the Minimum images

checklist for self hosted wordpress sites
checklist for self hosted wordpress sites

You should use the sprite image in wordpress theme. That will reduce the webpage loading time.

Use proper and optimized CSS properties

You should use the proper CSS. Dont repeat CSS code. like float, color, margin.

Test the Theme in IE7, IE8 ,Firefox, Safari and Google Chrome

Your theme need to be cross browser compatible.

Use only External CSS

Dont use the inline CSS in Theme.

Use Jquery

Jquery is very popular and simple and seo friendly for wordpress site.

Use the Sidebars in your theme

In sidebar you mostly put the links and ads. That is very important for SEO.

Put the Tag and category links

You should put the tags and category links in theme.

Make Mobile friendly

You theme should viewable in iPhone, iPad, Blackberry mobile devices.

Check in WordPress site

  • Check Robots.txt file
  • Put Site title
  • Get some good Tagline for the site
  • Create contact us email address
  • Put Share links ie. Twitter, Facebook, MySpace, RSS, LinkedIn etc.
  • Create Author’s profile: Email, Website, AIM, Biographical Info
  • Put the Google Analytics code in your site
  • Do web master varification
  • Use the SEO Meta Tags (Use the SEO Meta Tags plugin)
  • Submit your site to to Yahoo, Google, Bing
  • Use good wordpress plugins
  • Use the Permalinks (date and name. if do not want to show category in url then use ‘No Category Base’ plugin)
  • All Posts and Pages with genuine and useful articles
  • Create nice Categories and their structure (parent-child)
  • Remove broken urls (if urls not provided use ‘javascript:;’ in anchor’s href)
  • Use the Widgets and Menus with their urls
  • Put Akismet API key -For Spam protection.
  • Do setting for Media sizes (thumbnail, medium, large)
  • Uncheck the “Organize my uploads into month- and year-based folders” setting in media setting.
  • Use the SEO ultimate plugin.
  • Dont use the plugin for contact form

Here are some useful links which will be helpful to you

Best WordPress SEO Plugins for Optimize your WordPress Website

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