wordpress tutorial, wordpress get posts with custom field value. Many people use the custom meta fields in wordpress posts. Here given code snippet for same. In this article I will show you how to retrieve the custom field from wordpress post. For fetching the custom fields you just need to use the following code.
wordpress get posts with custom field value
$key_values = get_post_meta($post->ID, 'key');
If you are using normal post or custom post type above function will work. Here is another code for fetching the custom post type meta values.
wordpress tutorial, how to make an email address linkable in wordpress. Here we given very simple and short code which you can add in theme.
When ever we insert the URL , email in post we need to put the link manually. WordPress provided the way to automatically make the URL and Email clickable in wordpress post.
how to make an email address clickable in wordpress
You just need to add following code in your wordpress theme’s functions.php file.
wordpress tutorial, how to use wordpress shortcode in text widget. In your shortcode in your wordpress widget section you need to use only following code. From wordpress 2.5 version shortcode method is included in wordpress.
So using or choosing the image as featured image for post is another manual work we need to do. Info about. how to set post first image as featured image. We have SQL query for this.
From wordpress 3.0 version wordpress launched the feature called featured image. Many new wordpress themes are compatible with new wordpress version. So using or choosing the image as featured image for post is another manual work we need to do.
Many old wordpress website holder or blogger is having issue with this functionality. What they want is when they create the post they haven’t set the featured image, but they would like the featured image to default to the image that has been included in the post.
Some wordpress always use the first image as featured image but old post was not updated with featured image. They need to do manual work to set the featured image. I also faced same issue.
After doing some R&D I found the solution. If you want to set the your posts first image as featured image then use my following code.
For using the code you need to open your mysql database command prompt or phpmysqladmin program and select your wordpress database and execute the following query in that.
insert into wp_postmeta (meta_value, meta_key, post_id) select DISTINCT(ID), post_type , post_parent from wp_psts where post_type= 'attachment' and post_parent !=0 and post_status='inherit';<br /><br />update wp_postmeta set meta_key = '_thumbnail_id' where meta_key='attachment'
Using above sql query you will be able to set the featured image to your old and new post from post content. If you are having any issues with using this sql then write to me.
WordPress is having great setting for SEO purpose but many wordpress blogger did not know about that feature. WordPress has feature called update services. This service will ping when your blog is updated with new post or article.
Use WordPress Update Services for better SEO
This feature is very useful to reach the internet user faster than major search engine. WordPress provide the default http://rpc.pingomatic.com/ service to ping or update the content. Pingomatic is very power server for your wordpress blog.
For changing the Update services, Login to Admin panel. Go to Settings->Writing->Update Services section from using admin panel . When you see that text box you will only http://rpc.pingomatic.com/ link over there.
My advise to you is when you have good amount content in your blog or website then only use the multiple ping back services.
I used the following services in Update services option.
Above services will submit your site content to major content ping back service. That will boost your site SEO and visitors of your site. After using above ping back urls your site content will be available to users throughout internet faster than google.
Earlier I have blog in wordpressmu then after wordpress 3.0 version I decided to migrate to new version. I exported my all posts by using the wordpress export tool. Then I imported data into new wordpress installation. I got all my posts and category and all the data. Then I checked all my attachments.
Then I saw my media library I saw all the images listing are there but images are not showing in media library. Media Library not displaying images after importing posts. I personally faced issue and got frustrated. then I solved issue myself using mysql query trick.
Media Library not displaying images after importing posts
When I checked my database I saw the all the my attachments are listed in post table but images are not displaying. All the places I only saw the wp-includes/images/crystal/default.png image.
I did spend one hour googled for solving the issue but I did not find any solution for this. Than again I checked my Folder permissions and images files but I found all things are perfect.
Then I checked my database and I found the issue. in wp_posts table ->post_mime_type column one entry was missing. After seeing that issue I fixed the issue.
I used the following mysql quires using myphpadmin tool.
[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]
Update wp_posts set post_mime_type='image/jpg' WHERE guid like '%jpg%'
Update wp_posts set post_mime_type='image/jepg' WHERE guid like '%jepg%'
Update wp_posts set post_mime_type='image/png' WHERE guid like '%png%'
Update wp_posts set post_mime_type='image/gif' WHERE guid like '%gif%'
[/viral-lock]
After using above query I checked the my media library. I am able to see my all images in media library.
My advise to you is first take backup of your database and then use above mysql quires. Then use the above queries.
If you are imported post from other website then use following commands also.
UPDATE wp_posts SET post_content = REPLACE(post_content, 'NEW-DOMAIN-NAME', 'files/');
UPDATE wp_posts SET post_excerpt = REPLACE(post_excerpt, 'NEW-DOMAIN-NAME', 'OLD-DOMAIN-NAME');
UPDATE wp_posts SET guid = REPLACE(guid, 'NEW-DOMAIN-NAME', 'OLD-DOMAIN-NAME');
Above quires will change the domain location of file.
Many wordpress blogger always spending some time for speeding up there blogs. In this aritcle I will tell you how you can speed up your wordpress blog with easy steps. Loading your website is very important. If your blog or site not more fast then bounce rate of your website will be high.
speed up wordpress blog
There is apache module called zlib. which is used for compression.
zlib is a lossless data-compression library that will help you to serve your pages faster. This will compress the static data of your website. like images, css and media and javascript files. It compresses the PHP that WordPress sends to your visitor’s browser so that it displays much more quickly. Compressing and sending is much faster than sending the PHP in its full size format.
If you are using dedicated hosting service then easy to make changes in your files but if you are using the shared hosting then first you need to check zlib compression is available or not.
For checking zlib library create the phpinfo() file and see the zlib is there or not.
Mostly 99% shared hosting gives zlib compression facility. Just open your header.php file from your wordpres theme folder and following code in that file in top of file section.
When you put some URL and email address you need to manually add the link URL to that text. This action always takes the some time of wordpress blogger. WordPress has facility to add the links to your URL and email address automatically.
convert plain text URI to HTML links in wordpress
This facility is available in wordpress since wordpress 2.7 version but many wordpress theme and plugin developers never used this functionality.
WordPress provides the make_clickable() function for convert plain text URI to HTML links. This function able to convert URI, www, ftp, and email addresses. Finishes by fixing links within links. You just need to pass the string parameter to this method.
More detail information you can find in following file.
wp-includes/formatting.php.
You can use this method in your functions.php file also. Use the following code.
add_filter('the_content', 'make_clickable');
By using this code you are able to covert the URI, www, ftp, and email addresses in to link.
If you are having any issues or question about make_clickable method then please write to me.
Many times you want to show the popular posts in your wordpress theme and you use popular post wordpress plugin or widget for showing the popular posts in your wordpress theme. As much possible you need to avoid the wordpress plugins for minimal code.
most popular posts wordpress without plugin
With very easy steps you can fetch the most popular posts from your wordpress. Most common trick or technique is on comments base you can fetch the popular posts.
You just need to open your functions.php file from wordpress posts and put following code in file.
// Get Most Popular Posts in theme
function popular_posts_by_comments( $posts = 5) {
$popular = new WP_Query('orderby=comment_count&posts_per_page='.$posts);
while ($popular->have_posts()) : $popular->the_post();
?>
<li>
<div>
<a title="<?php the_title(); ?>" href="<?php the_permalink() ?>"><?php the_title(); ?></a>
<span><?php comments_popup_link('0 Comment', '1 Comment', '% Comments', 'comments-link', ''); ?></span>
</div> <!--end .info-->
<div></div>
</li>
<?php endwhile;
}
This is very easy code to fetch you wordpress popular posts. Here I am fetching only 5 popular posts from wordpress. You can fetch the multiple popular posts by changing the $post variable value.
In wordpress theme sidebar or footer section if you want to show the popular post then just use following code.
When we login to wordpress admin area that time we first saw the admin dashboard. Many tabs and section are not useful in admin dashboard section for wordpress admin and sometimes we don’t know what is that sections.
Remove Unwanted Meta Boxes from wordpress dashboard through wordpress theme
We saw the right now, recent comments, quick press, stat, recent drafts, incoming links, wordpress development blog, other wordpress news, plugins and more sections in wordpress dashboard section. Most of that section are not useful to wordpress admin. So is that better to remove unwanted section from dashboard.
For disable the dashboard section we are going to use the wp_dashboard_setup method. In wordpress dashboard there are multiple meta boxes listed. some of them as follows:
For removing the widgets or meta boxes from dashboard you need to open your functions.php file from wordpress theme folder and put following code in that file.