Welcome to ManageWP.org

Register to share, discuss and vote for the best WordPress stories every day, find new ideas and inspiration for your business and network with other members of the WordPress community. Join the #1 WordPress news community!

×

Community | paulund.co.uk | Aug. 2, 2016

Attempt At Scoring 100 On Google PageSpeed

Here Paulund is trying to reach 100 on Google PageSpeed, he shared his findings, his methods, shares even configuration, and at the end almost nailed it, Almost!

Attempt At Scoring 100 On Google PageSpeed

Community | paulund.co.uk | Aug. 2, 2016

With PageSpeed being so important to Google and other search engines they have created a nice tool to judge the speed and optimization of your website by using Google PageSpeed tool. Before PageSpeed
First I'm going to start off by running PageSpeed on paulund.co.uk. This site isn't exactly resource heavy so I'm expecting quite a high score to start with but there will be things we can do to improve the speed of paulund.co.uk.
As you can see on the first test running through PageSpeed paulund.co.uk is getting a score of 89/100 on desktop computers, this is a good enough score and I probably wouldn't have to do much work to get this to 100. But when you check the mobile score it's set to 73/100.
On the PageSpeed results page it tells you areas that your site needs to improve on. We can now run a speed test from WebPagetest and see what speeds the pages are loading on so we can try to beat this after making all the improves we need.
As you can see from this image it's currently loading in 1.52 seconds with a repeat view of 1.37 seconds, now that's pretty quick for a website but it could be better.
PageSpeed Best Practices
First we're going to look at some of the best practices Google

2 min read Donna Cavalier
Tutorials | paulund.co.uk | Mar. 1, 2015

Add Missing Alt Tags To Wordpress Images

While not ideal in most cases, for large old sites that have lots of images, and you just can't possibly get to them all, this is a great idea. I would only use it in such a situation, though, as the title won't really be reflective of the actual image in many cases.

Add Missing Alt Tags To Wordpress Images

Tutorials | paulund.co.uk | Mar. 1, 2015

Images are important for engagement with your visitors but the problem with images is that they mean nothing to search engines. The only way search engines can tell what an image is about is by reading the information inside the alt attribute. If you are using WordPress you can easily include images on the page by using the media library. This is where you can select the alt text for the image, but what if you don't have alt text on your images or you forget to enter the alt text?
You need a way to automatically populate your image tags with an alt attribute.
Below is a WordPress snippet to put into your functions.php file to search your content for images which don't have an alt attribute. If they don't have an alt attribute this function will add it in with a default of the post title.
function add_alt_tags($content)
{
global $post;
preg_match_all('//', $content, $images);
if(!is_null($images))
{
foreach($images[1] as $index => $value)
{
if(!preg_match('/alt=/', $value))
{
$new_img = str_replace('

15 min read Matt Cromwell
Tutorials | paulund.co.uk | Nov. 3, 2014

Improving WordPress Shortcode Usability

Great tutorial that has the end user in mind. Don't just support shortcodes in your plugin, make it as easy as possible for your users to insert them with variables into the content area.

Improving WordPress Shortcode Usability

Tutorials | paulund.co.uk | Nov. 3, 2014

In this tutorial we are going to talk about WordPress shortcodes and what I think is the missing piece with shortcodes in WordPress. First I'll start by saying I really like shortcodes, it allows you to give the author of the website full control of the content on the site and where it is positioned.
What Is A Shortcode?
A shortcode allows the user to run a PHP function at any point you want in the content. A default shortcode you get with WordPress is the gallery shortcode, to add a gallery to your website all you have to do is add [ gallery ] to the content area of your website.
The name inside the square brackets is the name of the shortcode that you want to run at this position of the content. WordPress will then search for shortcodes on the the_content filter and using the function do_shortcode() will run the functions at this point of the content, the return of these functions will then be output into the rest of the content area.
Shortcodes allow you to send extra parameters to the function by using attributes.
[shortcode_example attribute1="stuff" attribute2="things"/]
In the shortcode function the developer can now look up these attributes and use these values to change the

Development | paulund.co.uk | May. 21, 2016

Using Composer With WordPress

A nice introductory article on using Composer with WordPress. The article comes with resource and direct instruction.

Using Composer With WordPress

Development | paulund.co.uk | May. 21, 2016

In this tutorial we're going to investigate using composer as the dependency manager for WordPress. What Is Composer?
Composer is a dependency manager for PHP which allows you to easily manage any third party libraries within your application. You can specify an exact version you want to use on any of the third party packages. Composer will then look up the tag version of this package and download that version into your application.
When developing with WordPress you are dependent on multiple third party libraries for your website to work, things like the core WordPress code and the specific version you're running. Third party plugins from wordpress.org can change the functionality of your website so you're dependent on these running the latest version. This is the reason why composer can be used to manage the updates of your plugins, themes and the core WordPress code on your WordPress site.
As this is a dependency manager for PHP you don't have to limit yourself to just WordPress plugins you can use composer to manage generic PHP libraries.
Using composer within WordPress will mean when developing the application you don't need to commit any third party libraries to your own source

Tutorials | paulund.co.uk | Jan. 12, 2015

Programmatically Assign Menus To Theme Locations In WordPress

This article will show you how to Programmatically assign Menus To Locations In WordPress Themes

Programmatically Assign Menus To Theme Locations In WordPress

Tutorials | paulund.co.uk | Jan. 12, 2015

In this tutorial we are going to look at how we can programmatically set a menu to a menu location. In WordPress you assign a menu to a location by going to the menu page in the admin area and click on manage locations this will take you to the page /wp-admin/nav-menus.php?action=locations. From here you will see a list of all the locations assigned to your theme with a dropdown where you can choose what menu you want to assign to the location.
An example of when you will need to programmatically set this is on a plugin activation you create a number of new menus based on user role and want to assign these to a menu location. First this will need to get a list of menu locations, get a list of menus and assign the menu ID to the location.
Get All Menu Locations
First we need to get a list of all the registered menu locations in your WordPress theme to do this we can use the get_theme_mod() function, passing in the parameter of nav_menu_locations.
$locations = get_theme_mod( 'nav_menu_locations' );
This returns an array of key value pairs for the locations, the key being the ID of the menu location and the value is the menu term ID that is used in this location, so to change the menu

Tutorials | paulund.co.uk | Mar. 23, 2016

Get WordPress Image ID By URL

Paul Underwood shared this trick with full code example on how to get Image ID from an URL in WordPress, might come handy for Theme and Plugin Developer.

Get WordPress Image ID By URL

Tutorials | paulund.co.uk | Mar. 23, 2016

In a recent project I needed to automatically assign a image to a post from a URL. This situation happened where I had a library of image URLs which on the publish event of a new WordPress post we needed to check that the post had a featured image, if it didn't have a featured image then we automatically assign a image to this post. Therefore I had an array of image URLs we will use to randomly select an image to use as the featured image on the post. To programmatically assign an image to a post as the featured image you need to use the function set_post_thumbnail(), which takes two parameters a post ID and the attachment ID.
set_post_thumbnail( $postId, $attachmentId );
In WordPress a image that is added to the media library is called an attachment, so to add an image as the featured image on a post it first needs to be added to the media library before we can assign it to a post. In this situation I know that all the images in the array are added to the media library we just need to get the attachment ID to assign it to the post.
When an image is added to the media library it's classed as a attachment, which is added to the wp_posts table with a post type of attachment. This means

Community | paulund.co.uk | Nov. 12, 2014

Register New Post Statuses In WordPress

A Nice quick tutorial on how to change and create post statuses by Paul Lund.

Register New Post Statuses In WordPress

Community | paulund.co.uk | Nov. 12, 2014

WordPress posts allow you to have some form of workflow when editing your posts. This is done by assigning a post status for each stage of the WordPress posts. By default the WordPress will take up the status of Draft which tells WordPress to create a post but not to publish it on the front-end of the site, it will only publish it on the site when you hit the publish button and the post status is changed to publish.
Default Statuses
The default WordPress statuses are:
Publish - Viewable to public users on the front-end of the site.
Future - Posts which are scheduled to be published on a future date.
Draft - Incomplete post only viewable to registered users with the correct capability.
Pending - Post has been completed but awaiting someone with publish capabilities to publish the post.
Private - Post can only be viewed by admin users.
Trash - Posts which have been deleted.
Auto-Draft - WordPress will auto save drafts.
Inherit - Used by child posts such as attachments to determine the post status of the parent.
Create Custom Post Statuses
If you want to create your own post statuses to create your own workflow then WordPress allows you to register your own post statuses to use in your

Editorials | paulund.co.uk | May. 23, 2016

One Plugin Vs Lots Of Smaller Plugins

Upon a question on Twitter about if you prefer one single plugin with all functionality or lots of smaller plugin, this post highlight various people answer and explanation. Good read.

One Plugin Vs Lots Of Smaller Plugins

Editorials | paulund.co.uk | May. 23, 2016

Yesterday I asked this question on Twitter and was quite interesting to see the response to the question so I wanted to post it on here and open the discussion up to more people (other than those on Twitter) and see what people think. In the past of WordPress we see lots of articles about if you want to speed up WordPress then you need to reduce the amount of plugins that you have. If you know WordPress and how the development works you'll know that it doesn't make a difference to the amount of plugins you have installed but what the plugin does.
There are 1000s of WordPress plugins on wordpress.org some of them are huge plugins doing lots of different things and others are tiny which do a specific job.
An example of this question I'm going to use one of the most popular WordPress plugins is Yoast SEO, it's a great plugin and does everything you need to control SEO on your website. You can change the title format, social network tags, XML sitemaps, breadcrumbs, RSS settings and many more.
There are other plugins on wordpress.org that break up this code a bit by offering just XML sitemaps or a plugin just for breadcrumbs.
My question on Twitter is would you prefer to use a single large

9 min read Max Spiker
Tutorials | paulund.co.uk | Jan. 9, 2014

Create Your Own WordPress Login Page

In WordPress you can create your own users and user roles, you can even do this programmatically which means that you can create a register form so that visitors to your site can register to your site and login to a member's only area

Create Your Own WordPress Login Page

Tutorials | paulund.co.uk | Jan. 9, 2014

In WordPress you can create your own users and user roles , you can even do this programmatically which means that you can create a register form so that visitors to your site can register to your site and login to a member's only area. If you allow visitors to register as users of your site, they will have access to login to your admin area. This isn't too much of a problem if you set their roles to be able to do nothing in your admin area but this isn't very usable to your visitors.
It will be better if you can create a new login form , use the inbuilt WordPress user manager and redirect successful logins to a different area other than the WordPress admin area.
In this tutorial we are going to look at how you will create a new login form for users to be redirected to a different area.
Restrict Access To Admin Area To Only Admin Users
To start with we are going to restrict access to the WordPress Admin Area to only users who we want to be there, in this situation I'm only going to allow admin users to access the admin area.
In your WordPress theme functions.php file add the following code to block access to the admin area. function restrict_admin() { if ( ! current_user_can( 'manage_options'

3 min read Avi Joseph
Tutorials | paulund.co.uk | Nov. 19, 2013

Hide WordPress Update Notice To All But Admins

When you have built your site on an open source project like WordPress one of the benefits you get is continuous updates and improvements to the core code.

Hide WordPress Update Notice To All But Admins

Tutorials | paulund.co.uk | Nov. 19, 2013

When you have built your site on an open source project like WordPress one of the benefits you get is continuous updates and improvements to the core code. WordPress aims to release a couple of versions per year, when there is a new version of WordPress available to download there will be a notification bar at the top of your admin area. This notification bar will let you know that your WordPress version is out of date and that you need to update the core code.
WordPress Releases
It is highly recommended that whenever there is a stable release of WordPress to update as soon as possible, just so you are always running the latest code with the latest security updates .
The problem with this is when updating on a live site, without knowing the affects of the update. With each release WordPress is trying to improve it's codebase, this could mean that it will improve on old functions of code or even remove old functions of code.
If you have a plugin or theme that is using any of these old deprecated functions then it could break the functionality of your site or even bring down your entire site. For this reason you should always have a development site with the same plugins and themes where

9 min read Luis Godinho
Tutorials | paulund.co.uk | Dec. 21, 2013

WordPress Tables Using WP_List_Table

How to use the WP_List_Table class and see how to use this to display custom data in the WordPress admin area. Currently WordPress uses the WP_List_Table class to display data for all posts, pages, comments, users and plugins.

WordPress Tables Using WP_List_Table

Tutorials | paulund.co.uk | Dec. 21, 2013

WordPress it's not only a CMS it can be used as an application Framework, when it's being used as a framework you will find yourself adding custom data to your database using the $wpdb object and custom tables. When you have this in place within your application you will want a nice way of displaying the data in the admin area of WordPress . This is exactly like the posts edit screen it shows a table of all your posts, this comes with searching, sorting, filtering and pagination. It will be great if you can some how reuse this functionality to display your own custom data, luckily in WordPress you are able to reuse this functionality with any data and columns you want. Allowing you to send this data to a WordPress class and it will output the data in the same table and functionality as the edit post screen.
In this tutorial we are going to investigate using the WP_List_Table class and see how we can use this to display custom data in the WordPress admin area. Currently WordPress uses the WP_List_Table class to display data for all posts, pages, comments, users and plugins.
Creating Plugin
This tutorial we are going to create an example plugin which we can use to demonstrate the use

1 min read Avi Joseph
Tutorials | paulund.co.uk | Nov. 12, 2013

Multiple Users With WordPress Multisite

When you are using the WordPress multisite it's very easy to create a new site and straight away start using it just like your other WordPress sites.

Multiple Users With WordPress Multisite

Tutorials | paulund.co.uk | Nov. 12, 2013

When you are using the WordPress multisite it's very easy to create a new site and straight away start using it just like your other WordPress sites. In WordPress when you create a new site you are asked for the email address of the admin user for the site, if this email address is already …

Tutorials | paulund.co.uk | Nov. 11, 2013

Override Sidebars Per Page In WordPress

the ability to show different widgets on a per page basis

Override Sidebars Per Page In WordPress

Tutorials | paulund.co.uk | Nov. 11, 2013

In WordPress development you define what sidebars can be used on your theme, these sidebars will then appear on the widget dashboard screen where you can assign all the widgets that are placed in the sidebar. One of the areas that I've noticed with WordPress is the limitations you have with the widgets area. When …

Setup A WordPress Multisite

Tutorials | paulund.co.uk | Nov. 4, 2013

One of the best things about using WordPress is the multisite feature. This was introduced in WordPress version 3.0 and gives you ability to create a network of sites on the same install of WordPress. There are many other CMS's that provide this feature but WordPress makes them very easy to manage by allowing you to switch between different sites, share themes and share plugins. When you have turned on the multisite feature in WordPress the end user will now have the ability to create a brand new site whenever they want. You can customise the URL that you want to give the new site. As this runs off the same install of WordPress you can choose to either install the network sites on a different sub-domain or within a sub directory.
As these new sites use the same WordPress instance they are considered to be virtual sites as they do not have their own sub-directories, but they are given a blog ID in the database which is used to get the posts information for this site. When a new site is created WordPress will create a number of tables and prefix these with the new blog ID.
Configure WordPress For Multisite
By default WordPress is installed as a single site to enable multisite you need

2 min read Damien O'Neill

Load Google jQuery UI Theme CDN In WordPress

Tutorials | paulund.co.uk | Oct. 23, 2013

WordPress comes with a number of built in Javascript and Stylesheet libraries which you can use in your application. One of these libraries is jQuery UI which you can easily load into your website by using the function wp_enqueue_script . This loads in the Javascript required to have access to the core UI library, but jQuery UI comes with a number of modules such as tabs, sliders, accordions, datepickers etc. But to display these correctly on your website you need to load in the CSS themes for jQuery UI. WordPress does not have these themes by default but you can download them from the jQuery ui website.
jQuery UI
Instead of downloading these themes you can use these default themes from the Google CDN .
Below is the code you will need to load the correct version of the jQuery UI theme, first you load in the jQuery UI by using the wp_enqueue_script() . This value is added to the $wp_scripts object . From here we can get access to the jquery-ui-core where we can get the exact version of the library.
Once we have the version we can add this to the URL of the Google CDN and use this to load the theme stylesheet that we want.

Disable Auto Updates In WordPress

Tutorials | paulund.co.uk | Nov. 5, 2013

In the past when there is a new WordPress version release the site admin would have to log into the admin area and manually update their website. As of WordPress 3.7 the core development team have created a new feature called automatic updates.
This is done by using the new WP_Automatic_Updater class located in /wp-admin/includes/class-wp-updater.php .
This is not just for core updates it can also be used to automatically update themes and plugins. With this new class there are lots of information in the codex to use the auto updater class.
Configure Auto Updates
In the state of the word presentation in 2012 Matt Mullenweg made it clear that he wanted to introduce a feature for auto updates into WordPress.
Ever since seeing how useful the auto updates were in other software projects such as Chrome. This will automatically update the software in the background without telling the user that an update has taken place, if all goes well the user shouldn't even know that an update was happening. Since then WordPress have been working towards this vision and have done so with the WP_Automatic_Updater class.
But not all developers think that this is a good idea, as one day their website will

Free Premium Files For November 2013

Community | paulund.co.uk | Nov. 2, 2013

Each month the Envato marketplace brings you free premium standard files. Envato is a web marketplace where you can get premium files for different areas of your website. My favourite marketplaces are the script marketplace CodeCanyon and the theme marketplace ThemeForest.
Here are the files which you can get for free for November 2013.
Pure CSS3 Image Accordion
35 purchases at the price of $3.
Valid HTML5 layout
Pure CSS3 without JavaScript
Easy to use and customize
2 different styles (light and dark)
Fully responsive and fits to any width
4 caption positions (top, right, bottom, left)
Work in all CSS3 browsers and mobile devices
Get Free Now
I&Me Portfolio Web App
44 purchases at the price of $11.
Built on pure HTML5 and CSS3, ‘I&Me Portfolio Web App’ is an ‘HTML5 valid’ personal mobile portfolio website consisting of all important pages.
All Layered PSD files for each page included with the template.
The fonts typography used is that of open web standards – use of google fonts.
This template is compatible across all mobile and tablet devices and also on regular desktop interfaces since it is on complete liquid layout with aesthetics in mind.
HTML5 & CSS3 Standards
Native App-like

2 min read Avi Joseph

Remove Characters At Start And End Of A String In PHP

Community | paulund.co.uk | Oct. 9, 2013

Using the ltrim() function it will remove the whitespace from the start of the string, using the rtrim() function will remove the whitespace from the end of the string.

Store HTML View File In A Variable

Community | paulund.co.uk | Sep. 10, 2013

If you have used a MVC language before you would be familiar with the practice of separating your business logic from your HTML. The way this works in MVC language is that the framework will allow you to assign a view (HTML) to a controller (class). When the controller is instantiated it will have an action to display the view with the HTML for the page. Included with the separation is the ability