Share your WordPress page URL on social networking website by using a simple function

Share your WordPress post on facebook & other social networking website.

 

If you want to share your WordPress page URL on social networking website, it’s very simple to do.

Just place this function in your functions.php file, and call the function where do you want it to show.

 

[php]
<?php

function GetShareLinks() {

/* Your current page URL */
$URI = get_permalink();

/* The js script used for goolge plus share button */
$sharestring ='<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>’;

$sharestring .='<a href="https://pinterest.com/scriptarticle/" target="_blank"><img width="16" height="16" alt="Follow Me on Pinterest" src="http://passets-lt.pinterest.com/images/about/buttons/small-p-button.png"></a>
<a href="http://www.facebook.com/sharer.php?u=’.$URI.’"><img src="’.get_bloginfo(‘template_url’).’/images/facebook.jpg" alt="" /></a>
<a href="http://twitter.com/intent/tweet?text=’.$URI.’"><img src="’.get_bloginfo(‘template_url’).’/images/twitter.jpg" alt="" /></a>
<a href="http://www.linkedin.com/shareArticle?mini=true&url=’.$URI.’"><img src="’.get_bloginfo(‘template_url’).’/images/in.jpg" alt="" /></a>
<g:plusone count="false" size="small"></g:plusone>’;

return $sharestring;

}

?>
[/php]

 

You can also use this function in other website (non WordPress) site, you have to just replace the get_permalink() function by current page URL and update the social icons images path.

 

If you face any issue to use this, put your comment, I’ll help you 🙂

 

Display Recent Blog Posts Outside WordPress

Generally web master uses the WordPress for applying blog on their website.

 

Below is the code for the getting recent/latest post or list, can be applied to display recent posts outside anywhere in your WordPress website.

 

The key to use WordPress outside is include the wp-load.php file
Once the wp-load.php file is included, the entire wealth of WordPress functions will available for you to use.
This can be found under the root folder.

[php]
<?php

require_once ‘wp-load.php’;

// Recent 10 posts
$recent_posts = wp_get_recent_posts(array(‘numberposts’ => 10));

// Apply your design/html
echo ‘<ul>’;
foreach($recent_posts as $post) {
echo ‘<li><a href="’, get_permalink($post[‘ID’]), ‘">’, $post[‘post_title’], ‘</a></li>’;
}
echo ‘</ul>’;

?>
[/php]

If you want to pass more argument, you can do, below is the WordPress reference URL for wp_get_recent_posts function
http://codex.wordpress.org/Function_Reference/wp_get_recent_posts

 

You can also do your own custom queries with WP_Query.

 

Get a separate RSS feed for custom post type WordPress

rss feed for custom post type

Everyone is utilizing custom post types in their new WordPress sites as it is a very powerful and popular feature now days, now the next one is make a separate RSS feed for custom post type?

 

How can a user create a separate RSS feed for a specific custom post type in WordPress?

 

It’s so simple,it works just like creating a separate RSS feed for each category in WordPress.

 

You can simply go by typing this URL.

 

http://www.yourwebsite.com/feed/?post_type=location

 

Just change the post_type name to the one that you want to create a separate RSS feed for.

Are you looking to take it to the next level and make it for a specific custom post type and custom taxonomy? Well that is also not so hard at all.

 

http://www.yourwebsite.com/feed/?post_type=location&genre=newyork

 

Here genre would be the custom taxonomy, and new york would be the tag if you may call it that.
You can create a button in your site sidebar to link to that.You can also link this feed and create a separate feed burner feed for it.

 

For grabbing most popular WordPress custom post type plug-in,click on below URL.

 

http://wp-types.com/

 

 

Most useful 5 htaccess tricks every webmaster should know

Most useful 5 htaccess tricks every webmaster should know

1) Redirect your website visitors while you update or test your website

order deny,allow
deny from all
allow from 117.117.117.117

ErrorDocument 403 /showpage.html

<Files showpage.html>
allow from all
</Files>

Replace 117.117.117.117 with your IP address. Also replace showpage.html with the name of the page you want visitors to see.

2) Display a custom 404 error page

Your server displays a “404 File Not Found” error page whenever a visitor tries to access a page on your site that doesn’t exist.
You can replace the server’s default error page with one of your own that explains the error and links visitors to your home page.

ErrorDocument 404 /404.html

Replace 404.html with the name of the page you want visitors to see.

3) Handle moved or renamed pages

You’ve moved or renamed a page on your site and you want visitors automatically sent to the new page when they try to access the old one.

Use a 301 redirect

Redirect 301 /oldpage.html http://yourwebsite.com/newpage.html

Using a 301 redirect also ensures the page doesn’t lose its search engine ranking, as you know how important it is.

4) Prevent directory browsing

When there’s no index page in a directory, visitors can look and see what’s inside (directory structure and page listing).
Some servers are configured to prevent directory browsing like this. If yours isn’t, here’s how to set it up:

Options All -Indexes

5) Create user friendly URLs

Which of the two URLs below looks good?

http://yourwebsite.com/about
http://yourwebsite.com/pages/aboutus.html

Shorter URL is always better.

With htaccess and an Apache module called mod_rewrite, you can set up URLs however you want. Your server can show the contents of “/pages/aboutus.html” whenever anyone visits “http://yourwebsite.com/about”. Below are few examples

RewriteEngine on
RewriteRule ^aboutus/$ /pages/aboutus.html [L]
RewriteRule ^features/$ /features.php [L]
RewriteRule ^buy/$ /buy.html [L]
RewriteRule ^contactus/$ /pages/contactus.htm [L]