One place for hosting & domains

      Methods

      How to Schedule Posts in WordPress (3 Easy Methods)


      Publishing posts to your blog on a regular basis is essential. However, several issues might get in the way of consistent and optimized publishing, such as a full workload, trouble posting during high-traffic periods, or even the decision to take a vacation. Even expert bloggers need a little R ‘n R now and then.

      Fortunately, if you built your website with WordPress, there are a number of ways you can schedule your posts for publication ahead of time. Scheduling your posts enables you to put fresh content up on your site at regular intervals — without having to actually log in each time.

      In this article, we’ll explain the advantages of scheduling blog posts on your WordPress site. Then we’ll share a few methods for doing so, and go over some tips for troubleshooting issues that may arise during the process. Let’s dive in!

      Why It’s Smart to Schedule Your Blog Posts

      Creating a schedule for your blog posts is the best way to ensure that you always have fresh content. Plus, when you post regularly, readers will always know when to expect new articles. This can help keep them engaged and coming back regularly.

      On top of that, scheduling posts can help you manage your workload. When you have a busy week coming up, you can write your posts ahead of time and set a future publication date and specific time for each. Scheduled posts can also make it possible for you to take a vacation from your blog.

      In addition, assigning publication dates and times is useful for posting during peak traffic hours. Your readers may be most active on your site during a time of day you have to be away from your computer, for example. Automated publication lets you make new posts live at the ideal moment.

      How to Schedule Posts in WordPress (3 Methods)

      Fortunately, there are several ways to schedule posts on your WordPress website, so you can choose the method that works best for you. Let’s look at three of the most common options.

      1. Schedule Posts in the Block Editor

      WordPress has innate post scheduling capabilities, which you can access right from the editor screen. Let’s look at how to set a post up for automatic publication in the Block Editor (which you have access to if your WordPress version is 5.0 or higher).

      Open up the post you want to schedule, and in the sidebar to the right, select the Document tab. Under Status & Visibility, you’ll see that your post is set to publish Immediately by default.

      The Status and Visibility settings.

      If you click the link, it will open a calendar where you can select a future date and time. Once you’ve done so, Immediately will change to your specified publication time in the sidebar. Click anywhere outside the calendar to close it.

      Setting the publication date.

      When you’ve given your post one final read-through and are sure it’s ready to go, click on the blue Schedule button at the top of the editor.

      The Schedule button.

      You’ll have the chance to review and edit your post’s publication date and time and set its visibility status to Private, Public, or Password-Protected. WordPress will also point out any last-minute items you may want to address.

      Previewing the scheduled publication date and time.

      When you’re happy with your settings, select the blue Schedule button again.

      Scheduled post verification.

      You should receive a final notification that your post has been set to publish at the date and time you chose. That’s all you have to do!

      2. Set Up Scheduled Posts in the Classic Editor

      If you’re still using the Classic WordPress Editor, never fear. You can still easily set up scheduled posts. Simply head over to the post you want to schedule and check out the Publish widget.

      The Publish widget.

      Just like in the Block Editor, your post will be set to publish immediately by default. Click on Edit next to Publish immediately, which lets you access the date and time settings.

      The scheduled publication date and time settings.

      There’s no fancy calendar here, but it’s still easy enough to set your desired publication date and time. Just make sure to use the 24-hour clock.

      Then, click on OK when you’re done. After you’ve finalized your post’s details, select the blue Schedule button in the Publish widget.

      The Schedule button.

      You should receive a notification that your post has been scheduled and see its changed status in the Publish widget.

      Scheduled post verification.

      If you need to make any updates, you can do so by clicking on the blue Edit link next to any of the settings. Be sure to hit the Update button afterward.

      3. Use a Plugin to Schedule Posts

      If you want to access more advanced automatic publishing features, you may want to consider WordPress plugins. Let’s look at two of the best options.

      WP Scheduled Posts

      The WP Scheduled Posts plugin.

      WP Scheduled Posts adds an editorial calendar to your WordPress dashboard. You can drag and drop posts to schedule them so setting publication dates is fast and easy. This tool also helps you keep track of all your authors if you have multiple people creating content.

      You can even add new posts right in the calendar — save those great ideas you have for a future date. The plugin is free to download, but if you opt for a premium plan, you’ll gain access to additional features including the ‘Auto Scheduler’ and ‘Missed Post Handler.’

      CoSchedule

      The CoSchedule plugin.

      If you need a more complete content and marketing scheduling system, check out CoSchedule. While you’ll still have to follow the steps for scheduling posts in the WordPress editor as described above, with CoSchedule, you can manage your scheduled blog posts, social media content, and marketing campaigns from a single calendar right in your WordPress dashboard.

      You can download the CoSchedule WordPress plugin for free, but you won’t be able to do anything with it unless you also have a paid CoSchedule account. Plans for those accounts start at $80 per month.

      Troubleshooting Issues With WordPress Scheduled Posts

      Scheduling posts in WordPress is simple, but there are a few issues you may run into. Fortunately, the most common problems have easy solutions.

      Setting the Right Timezone

      First, it’s important to make sure that when you’ve chosen a publication date and time, they’re set to the right time zone.

      The WordPress Timezone settings.

      You can check your site’s time zone settings by going to Settings > General in your WordPress dashboard, and scrolling down to Timezone. There, you can see the time zone your site is currently set to, and change it if need be.

      Handling Missed Posts

      You’ll also want a failsafe in case something goes wrong, and a post you’ve slated for publication doesn’t go live as expected. For this, we suggest looking into a plugin such as Scheduled Post Trigger, which checks for and publishes missed scheduled posts.

      The Scheduled Posts Trigger plugin.

      This way, if your post doesn’t publish automatically for whatever reason, the plugin can still get your content up on your site (even if it’s a little late). If you’re using the premium version of WP Scheduled Posts, its ‘Missed Posts Handler’ feature works in much the same way.

      Unscheduling Posts

      Finally, there may be times when you’ve set up a post for future publication, and then you decide you want to publish it right away instead. To do this in the Classic Editor, head over to the Publish widget and click on Edit next to the date by Scheduled for. Change the settings to the current date and time, and then select OK.

      Unscheduling a post.

      Click on the blue button, which will say either Update or Publish. Once you do, you should receive a notification that your post has been published.

      Publishing an unscheduled post.

      In the Block Editor, this functionality works much the same. Change the scheduled date and time to the current moment, and click outside the calendar to exit the feature. The blue button at the top of the editor will now say Publish.

      Unscheduling and publishing a post. Note the blue Publish button.

      Select it, and WordPress will put the post up on your site immediately.

      Keep Us Posted

      Posting consistently on your WordPress blog is key to your site’s success. Scheduling your blog posts in advance can help you gain more loyal followers, while also making it easier for you to manage your site over time.

      Do you have any questions about how to schedule posts in WordPress? Follow us on Twitter and let us know!





      Source link

      How To Use Object Methods in JavaScript


      Introduction

      Objects in JavaScript are collections of key/value pairs. The values can consist of properties and methods, and may contain all other JavaScript data types, such as strings, numbers, and Booleans.

      All objects in JavaScript descend from the parent Object constructor. Object has many useful built-in methods we can use and access to make working with individual objects straightforward. Unlike Array prototype methods like sort() and reverse() that are used on the array instance, Object methods are used directly on the Object constructor, and use the object instance as a parameter. This is known as a static method.

      This tutorial will go over important built-in object methods, with each section below dealing with a specific method and providing an example of use.

      Prerequisites

      In order to get the most out of this tutorial, you should be familiar with creating, modifying, and working with objects, which you can review in the “Understanding Objects in JavaScript” article.

      For additional guidance on JavaScript in general, you can review our How To Code in JavaScript series.

      Object.create()

      The Object.create() method is used to create a new object and link it to the prototype of an existing object.

      We can create a job object instance, and extend it to a more specific object.

      // Initialize an object with properties and methods
      const job = {
          position: 'cashier',
          type: 'hourly',
          isAvailable: true,
          showDetails() {
              const accepting = this.isAvailable ? 'is accepting applications' : "is not currently accepting applications";
      
              console.log(`The ${this.position} position is ${this.type} and ${accepting}.`);
          }
      };
      
      // Use Object.create to pass properties
      const barista = Object.create(job);
      
      barista.position = "barista";
      barista.showDetails();
      

      Output

      The barista position is hourly and is accepting applications.

      The barista object now has one property — position — but all the other properties and methods from job are available through the prototype. Object.create() is useful for keeping code DRY by minimizing duplication.

      Object.keys()

      Object.keys() creates an array containing the keys of an object.

      We can create an object and print the array of keys.

      // Initialize an object
      const employees = {
          boss: 'Michael',
          secretary: 'Pam',
          sales: 'Jim',
          accountant: 'Oscar'
      };
      
      // Get the keys of the object
      const keys = Object.keys(employees);
      
      console.log(keys);
      

      Output

      ["boss", "secretary", "sales", "accountant"]

      Object.keys can be used to iterate through the keys and values of an object.

      // Iterate through the keys
      Object.keys(employees).forEach(key => {
          let value = employees[key];
      
           console.log(`${key}: ${value}`);
      });
      

      Output

      boss: Michael secretary: Pam sales: Jim accountant: Oscar

      Object.keys is also useful for checking the length of an object.

      // Get the length of the keys
      const length = Object.keys(employees).length;
      
      console.log(length);
      

      Output

      4

      Using the length property, we were able to count the 4 properties of employees.

      Object.values()

      Object.values() creates an array containing the values of an object.

      // Initialize an object
      const session = {
          id: 1,
          time: `26-July-2018`,
          device: 'mobile',
          browser: 'Chrome'
      };
      
      // Get all values of the object
      const values = Object.values(session);
      
      console.log(values);
      

      Output

      [1, "26-July-2018", "mobile", "Chrome"]

      Object.keys() and Object.values() allow you to return the data from an object.

      Object.entries()

      Object.entries() creates a nested array of the key/value pairs of an object.

      // Initialize an object
      const operatingSystem = {
          name: 'Ubuntu',
          version: 18.04,
          license: 'Open Source'
      };
      
      // Get the object key/value pairs
      const entries = Object.entries(operatingSystem);
      
      console.log(entries);
      

      Output

      [ ["name", "Ubuntu"] ["version", 18.04] ["license", "Open Source"] ]

      Once we have the key/value pair arrays, we can use the forEach() method to loop through and work with the results.

      // Loop through the results
      entries.forEach(entry => {
          let key = entry[0];
          let value = entry[1];
      
          console.log(`${key}: ${value}`);
      });
      

      Output

      name: Ubuntu version: 18.04 license: Open Source

      The Object.entries() method will only return the object instance’s own properties, and not any properties that may be inherited through its prototype.

      Object.assign()

      Object.assign() is used to copy values from one object to another.

      We can create two objects, and merge them with Object.assign().

      // Initialize an object
      const name = {
          firstName: 'Philip',
          lastName: 'Fry'
      };
      
      // Initialize another object
      const details = {
          job: 'Delivery Boy',
          employer: 'Planet Express'
      };
      
      // Merge the objects
      const character = Object.assign(name, details);
      
      console.log(character);
      

      Output

      {firstName: "Philip", lastName: "Fry", job: "Delivery Boy", employer: "Planet Express"}

      It is also possible to use the spread operator (...) to accomplish the same task. In the code below, we’ll modify how we declare character through merging the name and details objects.

      // Initialize an object
      const name = {
          firstName: 'Philip',
          lastName: 'Fry'
      };
      
      // Initialize another object
      const details = {
          job: 'Delivery Boy',
          employer: 'Planet Express'
      };
      
      // Merge the object with the spread operator
      const character = {...name, ...details}
      
      console.log(character);
      

      Output

      {firstName: "Philip", lastName: "Fry", job: "Delivery Boy", employer: "Planet Express"}

      This spread syntax in object literals is also known as shallow-cloning.

      Object.freeze()

      Object.freeze() prevents modification to properties and values of an object, and prevents properties from being added or removed from an object.

      // Initialize an object
      const user = {
          username: 'AzureDiamond',
          password: 'hunter2'
      };
      
      // Freeze the object
      const newUser = Object.freeze(user);
      
      newUser.password = '*******';
      newUser.active = true;
      
      console.log(newUser);
      

      Output

      {username: "AzureDiamond", password: "hunter2"}

      In the example above, we tried to override the password hunter2 with *******, but the password property remained the same. We also tried to add a new property, active, but it was not added.

      Object.isFrozen() is available to determine whether an object has been frozen or not, and returns a Boolean.

      Object.seal()

      Object.seal() prevents new properties from being added to an object, but allows the modification of existing properties. This method is similar to Object.freeze(). Refresh your console before implementing the code below to avoid an error.

      // Initialize an object
      const user = {
          username: 'AzureDiamond',
          password: 'hunter2'
      };
      
      // Seal the object
      const newUser = Object.seal(user);
      
      newUser.password = '*******';
      newUser.active = true;
      
      console.log(newUser);
      

      Output

      {username: "AzureDiamond", password: "*******"}

      The new active property was not added to the sealed object, but the password property was successfully changed.

      Object.getPrototypeOf()

      Object.getPrototypeOf() is used to get the internal hidden [[Prototype]] of an object, also accessible through the __proto__ property.

      In this example, we can create an array, which has access to the Array prototype.

      const employees = ['Ron', 'April', 'Andy', 'Leslie'];
      
      Object.getPrototypeOf(employees);
      

      Output

      [constructor: ƒ, concat: ƒ, find: ƒ, findIndex: ƒ, pop: ƒ, …]

      We can see in the output that the prototype of the employees array has access to pop, find, and other Array prototype methods. We can confirm this by testing the employees prototype against Array.prototype.

      Object.getPrototypeOf(employees) === Array.prototype;
      

      Output

      true

      This method can be useful to get more information about an object or ensure it has access to the prototype of another object.

      There is also a related Object.setPrototypeOf() method that will add one prototype to another object. It is recommended that you use Object.create() instead as it is faster and more performant.

      Conclusion

      Objects have many useful methods that help us modify, protect, and iterate through them. In this tutorial, we reviewed how to create and assign new objects, iterate through the keys and/or values of an object, and freeze or seal an object.

      If you need to review JavaScript objects you can read “Understanding Objects in JavaScript.” If you would like to familiarize yourself with the prototype chain, you can take a look at “Understanding Prototypes and Inheritance in JavaScript.”



      Source link