Categories
WordPress Workshop Novi Sad

Sixth WordPress Workshop – Novi Sad

During the sixth WordPress workshop in Novi Sad, we first took a look at the solution of the task that I gave to the attendees at the previous workshop. We then covered creating membership sites – the WordPress built-in way and by using a plugin Ultimate Member.

Creating a Plugin

During the fifth WordPress workshop, we created a plugin which adds the alt value to all Gravatar images. For homework, everyone was supposed to create a plugin of their own which would add the name of the author in front of the title of each post and says:.

If the post title is Hello World, the end result (instead of just the post title) should be Daki says: Hello World (if Daki is the name of the author of the post). And as a bonus task, the plugin should also add the author’s Gravatar image to the title with the dimensions of 15x15px.

This is a task I made up so there’s no copy/paste solution available online πŸ™‚ However, for finding the right hooks and functions to use, Google is your best friend.

Here’s the function that needs to be added to the plugin in order to achieve the aforementioned result:

https://gist.github.com/davoraltman/f682c24be33fa5e71d6ec452838ea2b0

And now, the copy/paste solution is available online πŸ™‚

Creating a Membership Site

There are two main ways for creating a membership site in WordPress. The first one is to use the built-in WordPress functionality and publish posts/pages as Private or Password protected. However, this is not a very flexible solution as you can’t really control user capabilities, there’s no members area, and you’d lack lots of really cool options that membership sites have.

Enter Ultimate Member. There are many WordPress membership plugins available online but Ultimate Member is the one I use the most and always recommend. It’s user-friendly and easy to set up. They have decent documentation available and there are quite a few free and premium extensions you can use.

Here’s a video walkthrough of creating a membership site by using the Ultimate Member plugin:

I’m speaking in Serbian but the whole interface is in English

During the video, I’m basically going through the tasks I gave the attendees in order to practice creating a membership site:

  • Install and activate Ultimate Member on a site created with the Local by Flywheel application.
  • Create the default Ultimate Member pages and add them to the menu.
  • Create a new user role that will be the main registration role.
  • Allow this role to log into WP Admin and to publish and edit its own post.
  • Modify the existing registration form so that it applies only to the new role you created.
  • Modify the existing profile form so that it applies only to the new role and allow this user role to insert the following info – Country, Birth date, and YouTube video.
  • Add 2 new pages that will be accessible only to the logged in users.
  • Add these 2 pages to the menu.
  • Modify the menu so that the 2 newly created pages can only be displayed to the logged in users. Do the same for the Logout, Account, and User pages.
  • Modify the members directory so that it can be searchable. The searchable users should be only the users who are assigned the newly created role.
  • The search can be filtered by Country.
  • You can’t see the admin user in the members directory.
  • Register as a new user in the browser incognito mode and fill in your profile.
  • Create a new user via WP-CLI and set the new role to this user.
  • Log into the site as the second user you created (in a new browser) and fill in your profile.
  • Check the search functionality and whether it’s working properly.
  • With each user, publish one post and add one comment to the restricted pages you added before.

Next

If you’re interested in exploring different membership plugins, Chris Lema has a really nice series of posts on this subject.

As for our WordPress workshops, next Saturday will be the last workshop this year. We’ll have three speakers joining us who will talk about their WordPress beginnings and how they made a career in WordPress. I hope this will further inspire the attendees to dive into WordPress deeply. In my humble opinion, it’s the perfect ending for the workshops πŸ™‚

Categories
WordPress Workshop Novi Sad

Fifth WordPress Workshop – Novi Sad

On Saturday, November 23rd, we had our fifth WordPress workshop in the Startit center in Novi Sad.

Terminal and WP-CLI

We went through Linux terminal basics and then we jumped into WP-CLI. We learned how to create, update, and delete users on the site, how to install, activate, deactivate, and delete plugins and themes, and how to perform a full backup of a WordPress website in a few seconds with WP-CLI and Linux commands:

wp db export – creates a database backup
tar cfz backup.zip . – creates a backup of all files and folders in the WordPress installation

We also skimmed-through the other fantastic options WP-CLI offers like:

We also took a quick look at the full documentation of all WP-CLI commands.

WordPress Plugins and Hooks

We inspected the code of the Hello Dolly plugin and based on its example, we checked the different hooks that WordPress offers – actions and filters.

We then created a simple plugin that adds the alt value to all Gravatar images. We also explored the forums where support for WordPress.org websites, plugins, and themes is provided by the volunteers.

I also provided all the attendees with the list of my plugins of choice for a WordPress website.

WordPress Translations

We explored the Languages folder in a WordPress installation and .po and .mo files. We checked the main WordPress translation website and we explored the Serbian locale.

SEO

We touched the main concepts of SEO and what are the most important things to work on. I plan on writing a separate article on this subject at some point.

Next

Next Saturday, we’ll be creating a membership website and a webshop.

Categories
WordPress

Fixing Broken Links on a WordPress Website

While maintaining a WordPress website, one of the things to regularly check is whether your site has any broken links. Broken links are not only a bad experience for the visitors but they can also have a negative impact on your site’s SEO. Luckily, there are a few tools you can use to quickly check and fix any broken links on your site.

Broken Link Checker

Broken links are essentially links that don’t work. If you click on them, they lead to a 404 page or to a page that doesn’t load at all.

Broken Link Checker

Every couple of months, I perform a quick audit on my website to see if any broken links appeared. I use a free online tool called Broken Link Checker. You simply enter the URL of your website into the field and it will scan your site and check for broken links.

There are two main different types of broken links you’ll encounter:


Outbound Broken Links

When there’s a link on your site which leads to another site, that’s an outbound or external link. If that external site or that particular external page you linked to stops working at some point, your site is left with a broken link.

Example: While writing a post about chocolate, you linked to an article that provides a fantastic recipe for making homemade chocolate. After a couple of months, you check your site with Broken Link Checker and you find out that the homemade chocolate recipe link you added is broken. Their site doesn’t exist anymore. This is bad news for folks after that excellent recipe that’s not there anymore but it’s also bad news for your site because it now has a broken link.

When this happens, I suggest going into your article and manually fixing this. Try checking whether they changed their domain name and let the old one expire. Or maybe they just changed the slug of their article but forgot to add a redirection (we’ll touch this subject later in the article). There probably won’t be many cases like that one but if you linked to the same link (or domain) that’s now broken in quite a few articles, you can then use either a plugin or WP-CLI to fix this relatively quickly.

Fixing With a Plugin

If you opt for the plugin solution, I can suggest installing Velvet Blues, and once you activate it, navigate to Tools -> Update URLs inside your WP Admin area. You’ll see the following screen where you can update all references of the old URL to the new URL.

Velvet Blues screen

Fixing With WP-CLI

With WP-CLI, you can use the search-replace command:

wp search-replace oldurl.com newurl.com

(I’d suggest always running a --dry-run first, though, to quickly check on how many places the link appears)

Inbound Broken Links

Whenever you write a post, it will gain a unique slug. For instance, when you check the URL of this article:

https://davor.blog/fixing-broken-links-wordpress-website

The part fixing-broken-links-wordpress-website would be the slug. You can change the slug of an individual article inside the Permalink box of the Edit screen of an article:

Permalink box

However, if you were to change the slug of your article, the old permalink containing the old slug would lead to a 404 page not found. And if the post was already indexed by Google or linked on another site, someone who clicks on the link would not be able to find that post.

This might be the very case of our aforementioned chocolate recipe example. They might have ended up with a broken inbound link which in turn caused your site to have a broken outbound link. No good!

Whenever you change a slug of any post or page on your site, I’d suggest always adding a 301 redirection. Until recently, I was using the Simple 301 Redirects plugin for this but when I started using the RankMath SEO plugin (h/t to Milan), I found that it can automatically import all redirections from Simple 301 Redirects and then have you manage them directly inside RankMath’s settings.

This is what the redirections screen looks like on my site now:

Redirections screen in RankMath on my site

Whenever I changed a post’s slug in the past, I added a redirection to the new slug thus making sure there are no broken internal links. However, RankMath automatically adds a new redirection from the old permalink to the new one so I don’t even need to do this manually anymore. That’s absolutely amazing, RankMath!

I can now be sure that if someone linked to any of my posts with the old slug on their own site (or found the old link on Google), that link would no longer be broken and it would automatically redirect to the new link. Something that the homemade chocolate recipe author should have done as well!

Another case of broken inbound links happens after you perform a site migration and change your domain name. To remedy the broken links on your site, you would need to use the aforementioned Velvet Blues plugin or WP-CLI command.

Conclusion

Having broken links is something everyone should avoid. Performing a regular audit with Broken Link Checker and fixing broken links, improves the visitors’ experience and also makes the relationship between Google and your WordPress website just a bit better 😎

Categories
WordPress

WP-CLI Intro

Stumbled upon this great article about WP-CLI. It offers a very nice intro to the WordPress world of WP-CLI and what can be achieved with it. Good read! πŸ“–