Paulund

Snippets Category

Add Additional Links To The WordPress Plugin Admin

Here is a useful snippet submitted by SHelfinger.EU.

When you activate a plugin in WordPress the author can place links in the plugin dashboard screen to show the users of the plugin links back to the plugin homepage, support page, FAQs or a way to contact the creator of the plugin.

By default WordPress will add the name of the author and a link back to the plugin homepage.

Using this snippet you can add extra links to this section like the image below from the Antivirus WordPress plugin.


Read More →

Display The Number of Database Queries In WordPress

When you are preforming maintenance on a WordPress blog one of things you need to check for is the speed of your WordPress database. You need to make sure that the amount of queries is down to a minimum and that there isn’t anything holding up the database.

In WordPress there is a couple of inbuilt functions that allow you to display the amount of SQL queries and the time it took them to run on any page.

Using this display you can then see what affect different changes make to your WordPress database.

Some of the tips mentioned in 11 Steps To Speed Up Your WordPress Site talk about database optimisation and reducing database calls by caching. It is very useful to take note of how long a page takes to load before and after you make these changes to see what affect they have.

Read More →

Add Search Form To A WordPress Menu

Wordpress

WordPress comes with the functionality to create menus in the dashboard area, from here you can select pages or custom custom menu items to make up your menu.

Menus are normally going to be display at the top of the page to give the visitor easy access to your main pages. But this top navigation bar is also a good place to have your search box so if people can’t find what they are looking for then they can use your search box.
Read More →

How To Exclude Posts From Search

Keywords

There may be times when you have a little rant of make a mistake in a post and want to exclude this from the in-built WordPress search functionality.

There is a way you can intercept the WordPress search functionality and exclude certain posts from being displayed. All you have to do is find out the post ID and add it to the following function in your functions.php file.
Read More →

Automatically Create Meta Description From Content

meta-description

Meta description tags are still very much used by search engines, they provide the default text to be displayed in the search results.

The Meta description tags should have relevant keywords to the article to attract visitors to your site.

In WordPress it can be done by using SEO plugins, but if you don’t have these plugins installed or forgot to add the meta description to this plugin then here is the WordPress snippet for you.

This snippet will automatically take the first 125 characters of your content and add this into the meta description tag for the page.
Read More →

Display The Post Date In WordPress

If you are building a WordPress theme then there will a time when you want to display the date for the current post, luckily for you this is very easy with a WordPress function the_date().

The the_date function will return the date of the post or the set of posts if published on the same date. This function has the option of passing in 4 parameters.

  • The format.
  • HTML to place before the date
  • HTML to place after the date
  • Boolean if to echo the date or not.
< ?php the_date( $format, $before, $after, $echo ); ?>

Read More →

How to Remove Default WordPress Widgets

688px-widget-panel

By default WordPress comes with a number of different in-built widgets which allow you to easily add additional functionality to your WordPress theme.

But if you have a custom made theme then most likely you will not be using any of these default WordPress widgets. If your not going to be using the widget then it would be good to remove these completely from the widget dashboard.
Read More →