How to View and Control WordPress Cron Jobs

Recently, one of our readers asked if it was possible to view and control the WordPress cron job system in the dashboard. Cron is a technology to run scheduled tasks on web server. WordPress comes with its own built-in cron that allows it to perform scheduled tasks such as checking for updates, publishing schedule posts, etc. In this article, we will show you how to view and control WordPress cron jobs.

What is WordPress Cron? How it Works?

Cron is a technical term used for commands to run on scheduled time or at regular intervals. Most web servers use it to maintain the server and run scheduled tasks.

WordPress comes with its own cron system which allows it to perform scheduled tasks. For example, checking for updates, deleting old comments from trash, etc.

Plugins can also use it to perform tasks specified by you.

For example, your WordPress backup plugin can use WordPress cron to automatically create backups at given schedule.

Irresponsible use of WordPress cron by plugins can slow down your website. Specially, if you are on shared hosting.

If a plugin frequently performs resource intensive tasks, then you need to identify the issue and fix it.

Let’s take a look at how to view and control the WordPress cron system without writing any code.

View and Control WordPress Cron System

First thing you need to do is install and activate the WP Control plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Tools » Cron Events page to control cron settings.

WordPress Cron events

You will see a list of all cron events scheduled to run on your site using the WordPress cron system.

In the first column, you will see the name of the hook that runs the cron.

Hook names usually give you a hint at what this particular event does.

Most default WordPress hooks begin with a wp_ prefix, like wp_update_plugins, wp_update_themes, etc.

Your WordPress plugins may or may not use their own prefixes for their hooks. For example, yoast seo uses wpseo_ prefix.

You will also get to see when a cron will run next, and the time interval between next run.

The last column on the list allows you to edit, delete, or run a cron event.

Important: Be very careful about what you do with cron events and never delete a default WordPress cron event.

Now let’s suppose you see a cron event created by a WordPress plugin that is quite resource intensive.

First, you should check the plugin’s settings to see if there is an option to control it from there. If there isn’t, then you can click on the ‘Edit’ link next to the cron event to change it.

Editing a cron in WordPress

Clicking on the Edit button will open the ‘Modify cron event’ tab down below.

Here you can change how often you want the event to run.

Modifying cron settings

Once you are done, click on the save changes button to store your settings.

Adding Your Own Cron Events in WordPress

WP Control plugin makes it easy to add your own cron jobs to WordPress. Simply visit Tools » Cron Events page and scroll down to ‘Add Cron Event’ tab.

Add custom cron event in WordPress

First you need to provide a hook name for your cron event. Hook names cannot have spaces or special characters.

If the function you want to execute requires arguments, then you can provide those arguments.

Next, you need to tell WordPress when to run the cron next time. You can enter ‘now’ which will trigger cron immediately, ‘tomorrow’, ‘+2 days’, or ’25-02-2020 12:34:00′.

Lastly, you need to select a schedule. You can select hourly, twice daily, daily, or once a week. You can also make it non-repeating event.

Once you are done, click on the Add Cron Event button to save your changes.

You will notice that your cron event will now appear in the events list.

However, currently it does nothing because you haven’t told WordPress what to do when this event is triggered.

You will need to add your hook and a function that runs when the cron hook is triggered.

if ( ! wp_next_scheduled( 'wpb_custom_cron' ) ) { wp_schedule_event( time(), 'hourly', 'my_task_hook' );
} add_action( 'wpb_custom_cron', 'wpb_custom_cron_func' ); function wpb_custom_cron_func() { wp_mail( 'you@example.com', 'Automatic email', 'Automatic scheduled email from WordPress to test cron');
}

Don’t forget to use your own email address.

This function simply sends a test email to you when the cron runs. You can now scroll up the page and click on the ‘Run Now’ link next to your cron event to test it out.

Note: Using cron requires intermediate level programming and WordPress development skills.

That’s all we hope this article helped you learn how to view and control WordPress cron jobs. You may also want to see our ultimate guide to speed up WordPress and boost performance.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

How to Prevent Duplicate Post Titles in WordPress

Your blog post title and URL play an important role in SEO. Having a duplicate post title can negatively the affect SEO performance of your site. WordPress deals with duplicate post titles by adding a number at the end of URL slug. However these titles are still duplicate, and you should try to avoid them. In this article, we will show you how to prevent duplicate post titles in WordPress.

Prevent duplicate post titles in WordPress

How WordPress Handles Duplicate Post Titles

WordPress automatically uses the post title as URL slug.

In case of a duplicate post title, WordPress tries to distinguish the title by adding a number at the end of the URL slug.

Number in the post URL

Since both post titles are still using the same keywords, this could confuse search engines when deciding which post should be ranked for the keywords used in the title.

Avoiding Duplicate Post Titles in WordPress

If you are running a single author website, then you can easily avoid this by simply changing the title and removing the number from WordPress URLs. However, it’s a lot harder to keep track of when you are running a multi-author WordPress site.

But don’t worry, the solution we’re going to cover is going to help you prevent duplicate post titles and advise your authors to change them.

First thing you need to do is install and activate the Unique Title Checker plugin. For more details, see our step by step guide on how to install a WordPress plugin.

The plugin works out of the box, and there are no settings for you to configure.

Simply go to Posts » Add New and enter a unique post title. The plugin will check the post title and notify you that it is unique, and you are good to go.

Unique post title

You can now try again by creating another new post. This time use a title that you have already used for another post.

The plugin will notify you that this title is already been used.

Duplicate post title warning

It will not stop you from editing the post, saving it, or even publishing it.

However, the warning will let you and other authors on your website know that they should use an alternate title.

We hope this article helped you prevent duplicate post titles in WordPress. You may also want to see our step by step WordPress SEO guide for beginners.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

How to Add Audio Stories to Images in WordPress

Do you want to add audio stories to your images in WordPress? You can use it to add narration to your photographs, or simply create web based audio visual story books. In this article, we will show you how to easily add audio stories to images in WordPress.

How to add audio stories to images in WordPress

First thing you need to do is install and activate the Audio Story Images plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you need to visit Media » Add New and upload your image and audio file you want to add to the image.

Upload your audio and image files in WordPress

After uploading both files, you need to visit the Media » Library page. Next, click on the list view icon to display your media files in a list.

You will now notice a new column labeled ‘Audio Story’. You need to click on the ‘attach’ link next to the image you just uploaded.

Link image to the audio file

This will bring up a popup where you need to select the audio file you want to attach to the image.

Select your audio file

Go ahead and click on the select button to continue.

The plugin will now link your image and audio file to each other.

Audio and image files linked together

Now that your image is linked to the audio file, you can add it to any WordPress post or page.

Simply edit a post or page where you want to add the image and click on the ‘Add Media’ button.

Add image in a WordPress post or page

This will bring up the media uploader popup.

You need to select the image file you just uploaded and insert it into your post.

Select your image from media library

Once you are satisfied, you can either save or publish your changes.

After that click on the preview button to see your audio story image in action.

Audio story image in WordPress

The plugin will add a tiny volume icon on the top left corner of your image. Clicking on the icon will play the audio file linked to the image.

We hope this article helped you learn how to add audio stories to images in WordPress. You may also want to see our guide on how to find royalty free images for your WordPress blog posts

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

How to Add Falling Snowflakes in Your WordPress Blog

Have you seen sites adding snowflakes because of the holiday season? It is a common trend to change site design or add minor updates to reflect the specific season. On most websites, we see this type of effect in the winter season. In this article, we will share how you can add falling snowflakes in your WordPress Blog.

Adding Snowflakes in WordPress

First thing you need to do is install and activate the WP Super Snow plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Upon activation, you will notice the new ‘Super Snow’ menu item in your WordPress admin bar. Clicking on it will take you to plugin’s settings page.

WP Super Snow settings page

You need to click on ‘Yes enable Super Snow’ button to enable the plugin and click on the save all changes button at the bottom.

You can now visit your website to see snowflakes and snowfall in action.

Snowflakes in WordPress

The basic settings for the plugin would work for most websites. However, if you would like to change anything then you can click on the ‘Virtual Snow Blower’ tab.

Here you will be able to change the snowfall direction and upload your own images to be used for snowfall and snowflakes.

Advanced snowfall settings

We hope this article helped you learn how to add falling snowflakes in your WordPress blog. You may also want to see our list of 25 most useful WordPress widgets for your site.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Essential HTML for Editing WordPress Content

In today’s coding generation, HTML is a very basic language. For that reason alone, I am going to call this a beginner’s tutorial on HTML and its use in WordPress. There are several HTML tags that are vital for customizing content in a WordPress blog. I will concentrate on things that you cannot do with the WYSIWYG editor. The WordPress WYSIWYG editor is the tool in the WordPress admin that allows most WordPress users to know little or no HTML code at all and still make a somewhat decent looking blog post or page. However, if you know the basics of HTML that I will cover here, there are more content styling options available to you when developing a post or page in WordPress. That’s why it is essential to know a little HTML when adding content to your WordPress blog or website.

What are HTML Tags?

HTML tags are the basic building blocks of any web page. Even if a more advanced coding language is used to produce a website, there is still going to be some HTML output to the screen. WordPress relies heavily on PHP as its main language of choice for the backend. PHP however generates HTML for the front end of a WordPress site that visitors see when visiting your blog or website. So, while WordPress uses mostly PHP, PHP in turn uses HTML, so there is not getting around the use of HTML in WordPress.

Using HTML in the WYSIWYG Editor

The WYSIWYG editor generates HTML as well. In fact, you can click on the editor’s HTML tab and see the HTML that the editor produces as you insert text in the user interface. It is automatically converted to HTML using the Tinymce PHP and JavaScript class libraries that are part of the WordPress installation core files.

What some WordPress bloggers and users may not realize is that you can edit the HTML directly when viewing it in the HTML tab of the WYSIWYG editor and you can even see the changes live in the regular editor’s view when you switch back to the default tab. It isn’t recommended often to try and use much advanced HTML code in the WYSIWYG editor, but here is a list of safe tags to play with. Any of the following tags can be surrounded with greater than and less than signs to make a tag:

H1 – H6 – tags are header tags that display header text at six levels or sizes with one being the largest.

P – tags are paragraph tags and surround each paragraph of text leaving a space before and after each block of text.

br – tags are line break tags that force the text following them onto a new line when rendered in a webpage.

blockquote – tags are used to add style to a quotation by the author or other source in a blog post.

Opening and Closing HTML Tags

One thing it is important to understand about most HTML tags is that they normally have an opening tag and a closing tag. The opening tag is the tag, such as p for paragraph, surrounded by a less than sign before it and a greater than sign after it. Then the content the tag is to effect follows the opening tag. Finally, the closing tag follows the content the tag is to effect. The closing tag also starts with a less than sign and ends with a greater than sign. However, the closing tag also usually has a forward slash before the tag name so a paragraph closing tag would actually be /p surrounded by the less than and greater than signs.

More Complex HTML Tags

Above we covered some of the more simple HTML tags that are commonly used in WordPress. Now I want to get into some of the more complex tags in HTML that can also be used with WordPress. One such tag is the auto closing tag. An auto closed tag is one that doesn’t have an opening and a closing tag, but is only one tag. The br tag is a good example. An auto closing HTML tag is a single tag that also contains the closing slash inside of the less than and greater than signs. However the br tag can be used with or without the closing slash. In HTML5 it is proper syntax to use the slash though, so get used to doing so. Another example of an auto closing tag is the input tag which is normally nested within a form tag. The common usage of an input tag goes like this:


Notice how the slash is placed before the closing greater than sign.

Another example of more complex HTML tags are nested tags. Remember how I mentioned that the input tag is nested within the form tag normally? Well there are other cases where this is practically mandatory or at least proper coding. Once such case is with list tags. There are two main types of lists. There are ordered lists that use the ol tag and unordered lists which use the ul tag. Both also make use of the li tag nested inside of them. The following section shows a common use case scenario for each.

Ordered Lists

Ordered lists are lists that are numbered and look like this:

  1. item one
  2. item two
  3. item three

The above HTML would produce something like the following:

  1. item one
  2. item two
  3. item three

Unordered Lists

Unordered lists are lists that use bullets instead of numbers. The HTML for an unordered list looks like this:

  • item one
  • item two
  • item three

The above code produces the following effect:

  • item one
  • item two
  • item three

With either an ordered list or an unordered list, the listed items get surrounded by the li HTML tag. The group of li tags in turn get surrounded by the ul opening and closing tags.

Nested HTML Tags

I mentioned nested tags when discussing lists tags and form tags above, but the general concept of nesting tags can be used with many other basic tags as well. For example, you could have a p tag inside of another p tag and it would still work like in the following example:

This is the start of a paragraph

this is inside of the paragraph but a paragraph of its own

this is the end of the original paragraph.

The above code would produce the following effect:

This is the start of a paragraph

This is inside of the paragraph, but a paragraph of its own

This is the end of the original paragraph.

In essence, the effect is the same as if the coder would have used three p tags, but accomplished the same thing with two. That is not really the intended purpose of this. You will understand why this might be done after reading the next section on attributes of tags.

Tag Attributes

Another great thing about using HTML in WordPress is the ability to assign attributes to HTML tags to change their functionality. For example, the p tag or paragraph tag can use the align attribute to center align or right align the text inside that tag. Also, you can use the CSS style declaration like an attribute to change the color of the text inside the tag. Consider the previous nested paragraph tags with the following changes and it makes more sense:

This is the start of a paragraph

this is inside of the paragraph but a paragraph of its own

this is the end of the original paragraph.

The above would print a red line followed by a blue line followed by another red line, making the coder only have to enter two inline styles instead of three because of the nested p tags. The p tag has one attribute, the align attribute, but also HTML has global attributes that can be called inside almost any tag. The inline style attribute used in the above example is just one of many global HTML attributes. Read on to learn more.

Global HTML attributes

Attributes are assigned to an HTML tag to alter the behavior of whatever is inside of that tag. In WordPress, these can be applied in the HTML view of the WYSIWYG editor. Here is a list of some of the more common global HTML attributes that might be assigned to any HTML tag:

style – used for declaring inline CSS styles for a tag.

class – used for assigning a CSS class to the tag.

title – used to display extra information about an element. Often triggers an on hover event so that text is shown to the user when the mouse hovers over that element.

lang – specifies the language used in that element.

id = assigns a unique id to the element.

accesskey – indicates a shortcut key to allow the end user to focus on the element on the webpage.

draggable – a new attribute to HTML5 that determines that the element can be clicked on and moved around the screen by the user.

contenteditable – tells whether the content within an element is editable or not and is also new to HTML5.

As you can see from some of the possible attributes, there are some things that could be added to a WordPress blog using raw HTML code and attributes that couldn’t be done with the default WYSIWYG editor’s functionality.

Summary

I hope you have learned some useful HTML tricks for customizing WordPress in this tutorial. If you make use of both HTML tags and their attributes, there are lot of extra things you can do to your content on your WordPress blog or website. Don’t forget HTML is easy compared to most other coding languages, so try it today. You might have fun making changes that you couldn’t do before in WordPress. Enjoy your new possibilities.