Code Snippets
You can find useful code snippets in this section. We have collected huge amount of useful code to serve your needs. Also, if you have awesome tips to share, you can register now and start submitting and promoting your website.
simple way to make a multi-file upload by adding or removing input tags easly bu MONGID DESIGNS
This plugin allows you to fill-up any form elements with a simple line of code You can pass all the fields value at once with a JSON object (check examples below) it's very useful if, for example you want to dynamically pre-fill your form from a server side scripts.
WordPress provide feature to show your post randomly. You can find many tutorials talk about it. But, sometimes your emphasize in viewing images other than words. It happen when your sites talk about interior, artistic, photographic, or displaying products.
Use this shortcode to display a specific post’s comment count. All you have to do is add the post ID.
As ajax is async, if you or your user triggers the event too fast, it may cause multiple ajax call. Also if You wont to loop ajax calls, the solution to the issue is to queue your ajax call.
WordPress provide private feature to make your post or page only visible to other editors or site admin. Once a post is set to private, regular visitor won’t be able to read the post. Now, what a about if We want to hide only a part of the post? This code snippet will show You how to do it. Read More: http://www.dynamicwp.net/articles-and-tutorials/hide-a-part-of-wordpress-post-or-page/
This simple and handy jQuery filter return a single random item from a selection of items. Credit to Waldek Mastykarz.
Most of the WordPress blogger uses excerpt to display a short summary of articles. This snippet able to let your control the length of excerpt, and make a custom more text after the excerpt. It uses add_filter with excerpt_length and excerpt_more. This snippet only work with excerpt generated by WordPress, not working with the optional excerpt field in the backend.
Simple snippet to add script to your WordPress template footer without having to add it into your footer.php. You can use this to append Google Analytic Code by using add_action function and append your script to wp_footer. It's a cleaner solution so your html file always separate from Javascript.
After developing a few mobile websites in the past few months, I notice that I am reusing certain Javascript code in every project. Followings are the 10 Useful Javascript Snippets that I use for mobile sites. Note that some snippets require jQuery mobile framework.
If you are a Web Designer or Developer and looking for a CSS hacks then this post going to help you. In this post I am going to share 4 different types of CSS hacks you can use.
WordPress admin interface has became more intuitive now. In the admin page, You can see the main navigation menu detailing each of the administrative functions you can perform, grouped in collapsible tabbed panels on the left-hand side column.
By default, a WordPress website displays the blog page, which is your most recent posts, on the front page. But many WordPress users want to have a static front page or splash page as the front page instead. Fortunately, WordPress allows you to select a different page for your home page
When a contributor in a multi-user site see the post list in the admin page, he could see not only his posts, but also posts from other contributors. Even he couldn’t edit the other posts, this still could be a problem if there’s alot post already and he have to search from page to page to find his posts. How about displaying his post only? This snippet will show how to do it.
While customizing a WordPress site, sometimes We also need to configure, how our WordPress site display the search result. On our previous code snippet, I have showed how to exclude specific category from search result. This tutorial will be the reserve, display the posts from specific category only in search result.
A list of countries in select box can come in handy when you're building a form. I was searching around for a few times now, I think it will be a really handy and good addition to my code repository.
Sometimes, You might want to automatically limit the length of post title in the main page. This little wordpress hack will allow you to limit the displayed post title by a defined number of characters on your blogs home page.
Internet explorer does't support min-height, but this CSS method will allow it.
This Javascript code trim implementation removes all leading and trailing occurrences of a set of characters specified. If no characters are specified it will trim whitespace characters from the beginning or end or both of the string.
The comment live preview feature helps the comment writer to see what they are writing in the comment form as they write. This feature works well to help prevent errors in spelling and grammar by giving the user a chance to see what they are writing before they post their comment.
In todays tutorial, we will learn how to preload the images with jquery. With this feature your site can enhancing user exprience.
To help site visitor finding one or two categories, We can use default widget or wp_list_categories to list the categories. In some case, We want to display the categories along with their posts. Unfortunately, this default widget and function can’t perform that. But this snippet can. Read more : http://www.dynamicwp.net/articles-and-tutorials/how-to-list-categories-along-with-their-posts/
A quick and non javascript PNG hack. Just put this in a ie6.css file, and apply the class to any div or img that using PNG images with transparency. It doesn't support background repeat.
Usually, WordPress theme developer already provide a tooltip for post title. This tutorial, a very easy tutorial, will help you add a fancy jQuery tooltip for your WordPress post title, replacing the default one. Read more: http://www.dynamicwp.net/articles-and-tutorials/how-to-create-fancy-jquerytooltip-for-your-wordpress-post-title/
A simple htaccess code to redirect your website from www to non-www or vice versa. It's important concept in SEO because most of the search engine will treat www and non-www as separate website. As a result, you want all the traffics focus on a single domain name, thus, this htaccess code is a good snippet to know.
This handy command line snippets allow us to import and export databases or tables with mysql built in function. Mysqldump command can be configured to export databases, or just a table.
This Simple tutorial will show you how to add/insert code or advertisement etc. right after the
This article shows simple usage of WordPress hook. The hook we are using here is post_publish, to restrict a specific word from post title. Read More: http://www.dynamicwp.net/articles-and-tutorials/how-to-restrict-a-specific-word-from-post-title/
This clearfix hack is good to clearing floats without having to adding additional html tag. floating is quite a common technique to make a tableless layout, and it's really annoying how many times you have to create a div with clear float class in it. This hack will solve that problem, instead of creating a new div, you attach this class to the parent class. It works flawlessly.
Grouping articles in specific criteria, like category, date or alphabet, could always help visitors to quickly find one or two posts. In my previous tutorial, I’ve shared a code snippet to group posts aphabetically. This time, I’ll share the code to group posts by their author. Read More: http://www.dynamicwp.net/articles-and-tutorials/how-to-group-articles-or-posts-by-author/




















