WordPress Themes, Plugins, Tutorials, Tips And More...

Tag: Code Snippet Page 4 of 5

The Best Of WordPress Snippets – Part 1

Programming-7

How To Detect That Whether Your Website Is Access By A Mobile Or Not

You did get visitors via mobile but how you can keep a track of that. Well, using the following snippet below will let you detect that whether your website is access through mobile or not.

Snippet Source/Credit: WebDesignLedger.com

How To Display Categories Drop-Down Menu In WordPress

The following snippet will let you display categories drop-down menu in WordPress.

Snippet Source/Credit: Snipplr

How To Display WordPress Author RSS Feed On Author Pages Only

The following snippet will display the WordPress Author RSS feed on author pages only.

Snippet Source/Credit: Snipplr

How To Display Your Tags In A Dropdown Menu In WordPress

You did seen quite a time that you can display your categories in a dropdown menu format but what if you want the same for tags. In this, with the help of following snippet you will be able to display your tags in a dropdown menu in WordPress.

Snippet Source/Credit: WebDesignLedger.com

How To Exclude WordPress Categories On Secondary Front Pages

The following snippet will let you exclude WordPress categories on secondary front pages.

Note: You can change the number “4” below to whichever category you will want to exclude on secondary front pages.

Snippet Source/Credit: iamnotgoodartist.com

How To Get Category Slug In WordPress

The following snippet below will let you get category slug in WordPress.

Snippet Source/Credit: BestWPThemez.com

Best CSS Code Snippet Websites

There is no doubt that one will be requiring code snippets to bring in some amazing piece of cake walk in the piece of work. Then, there is no matter whether that person will be a designer, a developer, a programmer or any other. Context to same thought, in this article, I have collected the best CSS Code Snippet websites for you.

Code And Me

CodeAndMe

[Visit]

Dev Snippets

Dev Snippets

[Visit]

Stack Overflow

StackOverflow

[Visit]

CSS Tricks

CSS-Tricks

[Visit]

Joyent

Joyent

[Visit]

Snipt

Snipt

[Visit]

HTML5 Snippets

HTML5 Snippets

[Visit]

CSS Pop

CSS Pop

[Visit]

Snipplr

Snipplr

[Visit]

Smipple

Smipple

[Visit]

WordPress Snippets – Part 5

Programming-3

How To Add Custom Pinterest Button In Your WordPress Website

Using the following snippet will let you add custom pinterest button in your WordPress website.

Add to your header above the body tag

Edit and add to your page where you want your button to appear.

Snippet Source/Credit: flashalexander.com

How To Remove WordPress Standard Gallery Style

On simply adding the following snippet to your theme’s functions.php file, you will be able to remove WordPress standard gallery style.

How To Resize Image Using TimThumb

Using the whole timthumb script, which being saved as sized.php file in the theme directory, you will be able to resize image.

Snippet Source/Credit: Binarymoon

How To Position Admin Metaboxes Before Editor

With the help of the snippet below, you will be able to position admin metaboxes before editor.

Snippet Source/Credit: Snipplr

How To Set Adjacent Post By Alphabetical Order

Using the following snippet will let you get next and previous posts by alphabetical order.

Source: Snipplr

How To Simulate A View Of A Page With JavaScript Onclick

Using the following snippet, you will be able to simulate a view of a page with JavaScript onclick.

Snippet Source/Credit: Reiffs.dk

WordPress Snippets – Part 4

Programming-1

How To Restrict WP Admin Access To Certain Users

Thanks to snippet below, with adding it to your theme’s functions.php file of your theme, you will be able to restrict WP admin access to certain users.

Snippet Source/Credit: WordPress Codex

How To Store Dynamic Sidebar In A Variable

The use of the following snippet will let you store dynamic sidebar in a variable.

Snippet Source/Credit: Stack Exchange

How To Use Gravatars In Your Script

The use of Gravatars in recent times is on full rise and result of which more and more people want to use it in their script. This is where, the snippet below will help you achieve this and let you add Gravatars in your script.

Snippet Source/Credit: AppHP

How To Add Custom Styles To Visual Editor In WordPress

Using the following snippet will let you add custom styles to visual editor in WordPress.

Snippet Source/Credit: WordPress.org

How To Display Custom Posts With Pagination

By default, in WordPress, a page name and custom post type can’t have the same name. Well, using the snippet below, you will be able to display custom posts with pagination.

Snippet Source/Credit: WordPress.org

How To Add Custom Images Sizes To WordPress

The following snippet below will let you add custom images sizes to WordPress.

Snippet Source/Credit: Snipplr

WordPress Snippets – Part 3

Programming-2

How To Limit WordPress the_content By Words

With the help of snippet below, you will be able to limit WordPress the_content by words.

Snippet Source/Credit: StackExchange

How To List Author Comments On Author Page

Using the following snippet, you will be able to list all the author comments on authors page.

Snippet Source/Credit: StachExchange

How To No-Follow WordPress Tag Cloud

Simply add the snippet to your theme’s functions.php file and you will be able to no-follow WordPress tag cloud in your website.

Snippet Source/Credit: Snipplr

How To Paginate WordPress Posts

Adding the following snippet to your theme’s functions.php file, you will be able to paginate WordPress posts.

Snippet Source/Credit: Design-Ninja

How To Remove WordPress Version Meta

Using the following snippet in your theme’s functions.php file, you will be able to remove WordPress version meta.

How To Render Your Twitter Followers Count In Your WordPress Blog

Adding the following snippet to your theme’s functions.php file, you will be able to render your Twitter followers count. Also, remember to replace “planetabhi” with your own Twitter screen name.

Snippet Source/Credit: Snipplr

WordPress Snippets – Part 2

Programming-7

How To Get Template For WordPress Widget

Using the following snippet will let you get template for WordPress widget.

Snippet Source/Credit: Snipplr

How To Get WordPress Page Slug

The following snippet will let you get WordPress page slug.

Snippet Source/Credit: Snipplr

How To Have Custom Menus For Different Category/Page/Post

Thanks to the snippet below, one can now have custom menus for different categories, pages or posts.

Snippet Source/Credit: WordPress Code 1, 2, 3, 4

How To Have WordPress Domain Check

Using the following snippet will let you have your WordPress domain check.

Snippet Source/Credit: Snipplr

How To Integrate The WordPress Media Uploader Into Your Plugin

Quite most of the time, you do require the need that you will be able to integrate the WordPress media uploader into your plugin. Well, this can be possibly done with the help of snippet below.

Snippet Source/Credit: FatFolderDesign

WordPress Snippets – Part 1

Programming-4

How To Display Recent Posts From All Sites

The following snippet will display recent posts from all sites.

Snippet Source/Credit: Snipplr

How To Display Twitter Feed In WordPress

With an age of social media, it is very much important to display twitter feed in your WordPress website. Moreover, it is not only just for getting updates but also to encourage people more often with the tweets. To display twitter feed in WordPress, using the following snippet will let you achieve this.

Snippet Source/Credit: Smashing Magazine

How To Execute Shortcode From Custom Field

The snippet will let you add shortcode to a WordPress custom field while by default; the option is not available by WordPress.

Snippet Source/Credit: Leeboyce.co.uk

How To Generate Your Own Portfolio With Filtering Based On Taxonomy

Using the following snippet will let you generate your own portfolio with the help of filtering based on taxonomy.

Snippet Source/Credit: ToddWilson

How To Get An RSS Feed And Display Items With A Loop

Use of the following snippet will let you get an RSS feed and display items with a loop.

Snippet Source/Credit: DanGayle.com

How To Get Attachments For Post Or Page

Using the following snippet below will let you get attachments for posts or pages.

Snippet Source/Credit: Stack Overflow

MixBag WordPress Snippets Collection – Part 5 Of 5

Programming-6

How To Have WordPress Pagination In Your Website Without The Use Of Any Plugins

Without any second thought, WP-PageNavi is one such plugin which everyone knows well, which everyone love very much and which everyone wants to get installed in their WordPress website. But, certainly, just like our other snippets tips, for this also, we are having something for you. It’s pretty simple, on copying and pasting the following snippet in your WordPress website, you will be able to have the pagination active and that too without the use of any plugin.

Snippet Source/Credit: Smashing Magazine

How To Prevent WordPress To Compress Your JPG Files

By default, WordPress compress upload jpg image files. While it is a good practice but sometimes, you need not such things. To prevent this, all you have to do is to copy and paste the following snippet in your theme’s functions.php file and it will let you prevent WordPress to compress your jpg files.

Snippet Source/Credit: WP Snippets

How To Make Your Search Results Unlimited

By default, WordPress displays ten posts on the search result page while there are some from us, who wish to see unlimited number of search results on the same page. Putting the following snippet in your theme’s search.php, you will be able to do so. Start by finding the below code in your search.php file:

Once you found it, simply replace it with:

Snippet Source/Credit: WPHacks

How To Redirect Users To A Random Post

You do often wish that what will happen if there is something by which you will be able to redirect users to a random post. Are you? If yes, then let’s make your job easy here, pasting the following snippet to your page-random.php file will let you redirect users to a random post.

Snippet Source/Credit: Smashing Magazine

How To Change The Label In Your WordPress Blog

It is pretty much common that you want to customize the label of certain things, say “post” label to “article” in your WordPress blog. It can be done with just few lines of code, just simply copy and paste the following snippet in your theme’s functions.php file and you are done.

Snippet Source/Credit: Smashing Magazine

How To Speed Up Your Blog By Adding Caching Custom Queries

If you are looking onto a method by which you can speed up your WordPress blog, then this is one such which you have to definitely try. All you have to do is add caching custom queries in your blog and you will be able to speed up your website.

Snippet Source/Credit: WordPress Codex

How To Create A Dropdown Menu Of Tags

By default, WordPress offers dropdown menu of categories (through wp_ dropdown_categories() function). But, what if you will be requiring or wish to display your tags in a dropdown manner as well. Does it sound good? Yes, then simply paste the following code at the place where you want the dropdown menu to be displayed. Make sure to modify the code on line 5 as per your requirements.

Snippet Source/Credit: WPLover

How To Test Whether A Plugin Is Active Or Not

For one-to-many times, you did often considerably think over the context that what it takes exactly from the backend which says that whether a plugin is active or not. Well, if you too found yourself in such a situation and don’t know what solution to opt for, then all you have to do is to simply paste the following code below and it will let you know that whether a specific plugin is active or not.

Snippet Credit/Source: CatsWhoCode

MixBag WordPress Snippets Collection – Part 4 Of 5

Programming-2

Modifying Size Of Embedded Videos

Simply paste the following snippet on your functions.php file and you will be able to modify the size of embedded videos as per your requirements.

Snippet Source/Credit: Shailan

How To Automatically Delete Trash On Daily Basis

When you delete a post or a page or a comment, it goes in a Trash instead of being removed permanently. Using the following snippet will ease you job of deletion and will tell WordPress to automatically delete the trash itself. Simply copy and paste the following lines of code in your wp-config,php file and you are done.

Note: Make sure that you do replace 1 by X to empty spam comments automatically every X days.

How To Remove WordPress Version Number

WordPress, by default, publicly display its version number in both its RSS and Atom feeds. Well, while using the snippet, you will be able to remove it. Simply paste the following snippet in your functions.php file and you will be able to remove WordPress version number.

Snippet Source/Credit: Jeff Starr

How To Execute Shortcodes Inside Custom Fields

WordPress, by default, don’t allow shortcodes to be executed inside custom fields. While, if in case, you want to do it so, then this can be done by using the following snippet below. Simply paste the snippet to the page where you wish to display the results of the shortcode. While doing this, make sure you do change your_custom_field_here to the name of your selected custom field.

Snippet Source/Credit: Snipplr

Securing Your WordPress Blog Uploads Directory

Although WordPress is a very secure system one actually thinks of BUT since there is always a room open for more improvement, using the following snippet will let you secure your WordPress blog uploads directory.

To do so, first of all, create a file named .htaccess and paste the following code in it. Once you created it, upload the same into your wp-content/uploads directory. Remember at line 5 in the snippet below; make sure to add/update all the extensions you want to make it work for you.

Snippet Source/Credit: Jeff Starr

How To Easily Get Post Content By ID

Using the following snippet will let you easily get post content by ID. All you have to do is to simply use the get_post_field() function to get the post content and you are done.

How To Embed A Page Into Another Page In Your WordPress Blog

Using the following snippet, you will be able to embed a page into another page in your WordPress blog.

Snippet Source/Credit: CSS Tricks

MixBag WordPress Snippets Collection – Part 3 Of 5

Programming-3

How to easily enable/disable debug mode in WordPress

WordPress comes with a debug mode by which you will be able to grab the information which lets you know that what is wrong. In order to enable or disable the mode, all you have to do is to copy and paste the following snippet in your theme’s wp-config.php file.

Once done, simply add a GET parameter to the url of the page you’d like to debug:

Snippet Source/Credit: Joost de Valk

How To Get Rid Of HTML In Comments

People often put their HTML links in the comments in an urge to get a link back. Well, this sounds frustrating mainly for the website owner but not the people who perform such task. Well, if you wish to get rid of HTML in comments completely, then all you have to do is to copy and paste the snippet in their theme’s functions.php file.

Snippet Source/Credit: TheBlog.ca

How to make term edition easier

While WordPress does come with much in-built functionality but sometimes you require more, say like quick edition of a term (mainly category, tag or custom term). In order to achieve the above, all you have to do is to simply paste the following snippet in your theme’s functions.php file.

Once saved, add the following line of snippet on any category, tag or taxonomy template:

Snippet Source/Credit: Joost de Valk

How To Rearrange WordPress Categories Order

Adding the following snippet to your theme’s functions.php file, you will be able to rearrange WordPress categories order, completely the way you want it.

Snippet Source/Credit: Sebastian

How to set a maximum word count on post titles

Adding the following snippet to your theme’s functions.php file, you will be able to set a maximum word count on post titles.

Snippet Source/Credit: Pippin

How To Use WordPress Shortcodes In Theme Files

A person who has got even a little knowledge of WordPress does understand the importance of WordPress shortcodes. While, everyone who are aware of shortcodes, definitely love them out but unluckily, shortcodes by default can be use only in post and page editor area and not in theme files. But, well with the help of this snippet below, you can use a shortcode in a theme file too, all you have to do is to use the do_shortcode() function as shared below.

Page 4 of 5

Powered by WordPress & Theme by Anders Norén