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!

×

6 min read Brad Touesnard
Tutorials | deliciousbrains.com | Dec. 8, 2015

HTTP/2, HTTPS, Let's Encrypt and WordPress

HTTP/2 is awesome, but requires HTTPS, which is hard to setup. Let's Encrypt and WordPress can make HTTPS setup simple and help achieve a faster web sooner.

HTTP/2, HTTPS, Let's Encrypt and WordPress

Tutorials | deliciousbrains.com | Dec. 8, 2015

TL;DR — HTTP/2 is awesome, but requires HTTPS, which is hard to setup. Let’s Encrypt and WordPress can make HTTPS setup simple and help achieve a faster web sooner. My eyes are heavy, my head foggy. Kind of feels like I’m in a dream right now. A couple of hours ago I got home from Philadelphia, where I attended the WordPress Community Summit and the first annual WordCamp US over the past 7 days. And man, what a time.
There will be plenty of recap posts published this week, so instead, I thought I’d dig into one thing I got very excited about at the summit.
HTTP/2
Weeks ago I got really excited about HTTP/2 while researching it for
an episode of Apply Filters. (If you haven’t learned about HTTP/2 yet, I urge you to listen to that episode. I’m very proud of the work Pippin and I did on it.) I learned that adding support for HTTP/2 on your site gives it an instant performance boost. And if you already have HTTPS setup, enabling HTTP/2 is as easy as updating Nginx to version 1.9.6+ and adding http2 to the config file:
listen 443 ssl http2;
If you don’t have HTTPS setup, you have do that in order to get HTTP/2 as it is only supported over HTTPS.
HTTPS
Unfortunately setting up and managing

6 min read Tom Zsomborgi
Tutorials | kinsta.com | Sep. 10, 2015

WordPress REST API Basics

In this article we take a look at the basics of the REST API and how you can use it to make your website better.

WordPress REST API Basics

Tutorials | kinsta.com | Sep. 10, 2015

WordPress has been gradually moving away from being just a blogging for years now. The final nail in the coffin of that outdated perception is the REST API. As WordPress enters the arena of full web application capable frameworks, the REST API is what makes interaction through third parties part of the core system. Available right now in the form of the REST API Plugin, the goal of the project is to enable predictable, resource-oriented URLs, standardized return structures and to use HTTP response codes to indicate API errors.
In this article I’ll take a look at the basics of the REST API and how you can use it right now to make your website or web application that much better.
The Basics
Once you’ve downloaded and activated the plugin your site is ready to go and your API base path will be /wp-json/. This means that to get all your posts from an external application you can make a request to http://yoursite.com/wp-json/something.
In most cases the “something” in the URL will start with /wp/v2 which indicates that you are using version 2 of the API
The easiest way to try out the new API is to make sure you’re logged in to the website you’ve installed and activated the plugin on and

16 min read Iain Poulson
Tutorials | deliciousbrains.com | Mar. 19, 2015

A Developer's Guide to Contributing to WordPress Core

A great guide to getting started with contributing to WordPress core as a developer

A Developer's Guide to Contributing to WordPress Core

Tutorials | deliciousbrains.com | Mar. 19, 2015

Every month the team here at Delicious Brains have a “WP Core Contrib Day”, a day to give back to Core. This is an important day for us as we make our living from premium WordPress plugins. Using our skills to help keep WordPress core awesome just feels right. Also, all of us contributing a work day per month to WordPress Core is very close to the 5% contribution that Matt Mullenweg talks about in his 5 for the Future post. In this article I’ll discuss the basics for finding things to work on, how to handle the WordPress source code, how to submit your work and what you might expect to happen from there. This article is very much targeted towards PHP developers that already know how to set up a normal WordPress installation, but are looking to dive in and contribute back to WordPress Core.
As we’re all developers at Delicious Brains, on our WP Core Contrib Days we endeavour to find tickets for WordPress Core that we can contribute to by committing code. I’ll be focusing on that type of contribution, but there are many other ways to contribute and anything you can do is appreciated.
Where To Find Tickets
When we first started our contrib days last November the first big hurdle we encountered

1 min read Donna Cavalier
Tutorials | sterlinghamilton.com | Feb. 15, 2016

The WordPress Noob: Common Mistakes - Sterling Hamilton

Definitely a nice list for those new to WP. There are things there that I wish I'd known about when I first started.

The WordPress Noob: Common Mistakes - Sterling Hamilton

Tutorials | sterlinghamilton.com | Feb. 15, 2016

Sterling Hamilton I'm an avid student of Stuff & Things. I work with cool people & do some neat things now and again.

Tutorials | keycdn.com | Jan. 26, 2016

Google PageSpeed Insights: Scoring 100/100 with WordPress

We all know WordPress can be a tricky beast when it comes to conforming to best web practices. Here is a quick tutorial on how to achieve a 100/100 score on Google PageSpeed Insights with WordPress.

Google PageSpeed Insights: Scoring 100/100 with WordPress

Tutorials | keycdn.com | Jan. 26, 2016

Running speed tests with tools like Google PageSpeed Insights, WebPageTest, or KeyCDN’s site speed test are always a good way to help gauge your website’s performance. While these metrics can be very helpful it is also important to keep this data in perspective. While they can provide valuable information to help optimize your website, don’t forget about perceived performance, specifically the user’s experience. With that being said, see how we easily achieved a 100/100 score with WordPress and Google PageSpeed Insights. A lot of people try and strive for that 100/100 score on Google PageSpeed Insights. Some do it because they are trying to speed up their site and others because a client is demanding they meet this metric (yes, this happens more than you think). It is important to take some time though and think about why we are trying to achieve that 100/100 score. Don’t think of it solely from a metrics point of view. The whole reason Google developed PageSpeed Insights was as a guideline on best web performance practices to provide recommendations to optimize your site. And by following the guidelines hopefully you will achieve a faster website.
It is also important to remember that

Tutorials | scalewp.io | Feb. 4, 2016

WordPress at Scale

Interesting resource for running a high trafficed WordPress site to scale.

WordPress at Scale

Tutorials | scalewp.io | Feb. 4, 2016

No Description

11 min read Donna Cavalier
Tutorials | ubergizmo.com | Jun. 12, 2015

Web Hosting Support Accusing You Of Slow MySQL Queries? Read This

I like that there are normal ranges presented and solid examples so users have some kind of reference point to work from.

Web Hosting Support Accusing You Of Slow MySQL Queries? Read This

Tutorials | ubergizmo.com | Jun. 12, 2015

It happens to thousands of people each day: for some mysterious reason, their website –maybe a WordPress or Drupal site- has become very slow. The administrative area of the back-office takes many seconds to load (more than 2 seconds starts to be bad), and the whole thing becomes a pain to use. In extreme cases, the whole page could even time-out and return an “unable to serve page” message, which is every webmaster’s nightmare. After contacting your hosting company’s tech support, a technician takes a look at several log files, and returns with the dreaded answer: “I see some slow queries in your MySQL slow query log file, please optimize your application”.
Read: “it’s your fault, fix it”. But is your site really causing this? Maybe not.
Basic pre-requisites
As it is the case with any hosting issue, it’s always best to do whatever is within your power to trace the source of the problem. Keep in mind that most hosting support staff are not there to support your web app, but just make sure that the server runs normally (check your terms). Any hosting company that will officially support your app is definitely worth looking at, because many of the day-to-day problems come from the app

22 min read Tom Zsomborgi
Tutorials | kinsta.com | Dec. 12, 2016

How to Score 100/100 in Google PageSpeed Insights with WordPress

It needs some work and effort but achieving 100/100 score is possible. Follow the steps listed in the tutorial.

How to Score 100/100 in Google PageSpeed Insights with WordPress

Tutorials | kinsta.com | Dec. 12, 2016

Here at Kinsta we work with a lot of agencies and freelancers that deal with clients on a daily basis. It is not uncommon for clients or even a CEO of a company to ask their agency or WordPress developer to increase their Google PageSpeed Insights score. Google does a good job at marketing this tool to consumers, and many times, they don’t always understand that a perfect score isn’t the end of the world. This can definitely be frustrating at times. However, today we want to share with you some tips and strategies that can help you score a 100/100 in Google PageSpeed Insights with your WordPress site. How Important is Google PageSpeed Insights?
Google PageSpeed Insights is a web performance tool created by Google to help you easily identify ways to make your site faster and more mobile friendly, by following recommendations on best web practices. A very important thing to remember though is that you shouldn’t always obsess over scoring 100/100. This might not even be possible in all scenarios, depending upon how your WordPress site is setup.
We recommend looking at the speed of your site, more than the scores. Scores with tools like Pingdom, GTMetrix, and Google PageSpeed

3 min read Josh Pollock
Tutorials | joshpress.net | Nov. 11, 2015

I'm Making A WordPress REST API Course

I'm stupid excited to announce I've been working on a four part video course on the WordPress REST API. You can pre-order and save today:)

I'm Making A WordPress REST API Course

Tutorials | joshpress.net | Nov. 11, 2015

I’ve had so much fun teaching myself the WordPress REST API for the last year or so. Part of what has made the experience so great is sharing what I’ve learned a long the way — tutorials, WordCamp talks, Podcast appearances, a free ebook. I can’t decide what I love more — using the REST API to build custom APIs the WordPress way or sharing what I’ve learned. So, I’ll just keep doing both.
That’s why I’m happy to announce I’m working on a four part video course, teaching you how to use the WordPress REST API.
Actually, it is already in use by those doing the coolest stuff with WordPress.
WordPress just hit 25% market share among content management systems. That’s awesome, the more growth in our industry the more potential customers or clients there are for people like you and me who offer WordPress services and products. We know that there are a lot of negative opinions about WordPress out there. Some of them are fair, some of them are not.
The more times we can exceed the pre-conceived opinions about WordPress, deliver more “You can do that with WordPress?” moments, the more our industry will grow. I want you to be the one to deliver that “wow” moment to your clients. I want you to

Tutorials | keycdn.com | Mar. 3, 2016

Harness the Power of WP-CLI to Manage WordPress Sites

WordPress is known for being very user friendly. But what about for developers? WP-CLI might just be your new best friend.

Harness the Power of WP-CLI to Manage WordPress Sites

Tutorials | keycdn.com | Mar. 3, 2016

WordPress is well known for being very user-friendly, and that is one of the reasons it has become one of the most popular content management systems on the web. But when it comes to managing multiple WordPress sites and repeating the same operations over and over again it can become quite a tedious task for developers. And that brings us to WP-CLI, a set of command line tools to help speed up the development process and accomplish tasks more efficiently and quickly. Compared to tools like ManageWP, which are limited by features provided within the UI, WP-CLI is much more powerful! WP-CLI’s mission is to be, quantitatively, the fastest interface for developers to manage WordPress. – wp-cli.org
What Is WP-CLI?
WP-CLI is an open source set of command line tools to help make web developers lives easier when it comes to managing WordPress installations. You can install WordPress (including Multisite), update plugins, take backups, perform database operations, publish content, manage WP-Cron events, and perform hundreds of other tasks without ever touching your web browser. If you prefer working from the command-line then WP-CLI is your friend!
WP-CLI was originally created by Andreas Creten

8 min read Matt Cromwell
Tutorials | calderawp.com | Aug. 8, 2016

Creating A Killer Contact Us Page For Your WordPress Site

Nice walkthrough of creating a "killer" Contact Us page. Honestly, I think I most often neglect to give the Contact Us page its due attention.

Creating A Killer Contact Us Page For Your WordPress Site

Tutorials | calderawp.com | Aug. 8, 2016

Too often, when creating a WordPress site, designers neglect the contact us page. After spending days and days contemplating every element in the homepage, a lot of designers neglect the ‘Contact Us’ page. They simply slap on a generic form, press publish and forget about it. If you actually examined it, you would find that the contact page is one of the most visited pages on your website. More often than none it is actually the most visited page altogether. Hubspot named the contact page one of the 4 most important pages on a website.
Bad “Contact Us” pages can lead to your clients not getting the proper support. It can also lead to your potential clients getting the wrong impression about your service, and may cause a list of other negative effects.
This is why I wanted to show you a step by step guide on how to create an effective contact page on your website. You don’t have to incorporate each and every point I make in your site, but investing time on improving your contact us page will surely improve your website visitor’s experience. It will also help increase your site’s conversion rate.
In this article I will show how to build the contact

21 min read Steven Gliebe
Tutorials | pippinsplugins.com | Jul. 31, 2015

How to Properly Format and Enhance Your Plugin's Readme.txt File for the WordPress.org Repository

David Decker shares tips on preparing a WordPress plugin's readme.txt file. This is great for first-time plugin authors and perhaps those of us not taking full advantage of the readme file.

How to Properly Format and Enhance Your Plugin's Readme.txt File for the WordPress.org Repository

Tutorials | pippinsplugins.com | Jul. 31, 2015

When beginning writing plugins for WordPress, most developers will publish the fruits of their work in the official WordPress.org Plugin repository. It’s a great way to get into plugin development for your favorite CMS. I started this myself in June 2011 and so far it has gotten me lots of experience on how to code better and manage the whole process. My Experience
If you’ve already published on WordPress.org or plan to do so, your plugin or theme is required to provide a so-called “readme.txt” text file. This is required because the repository parses it with Markdown language and draws all appropiate information from it, which is then displayed on the public repository. The header of that file also controls all aspects of the title, tagging, author, donate link etc. for your plugin or theme.
So, in this tutorial I’ll give you a lot of tips on how to do it the right way, based on my experiences over the last six months. I’ve seen so many great plugins in the repository but only a few have great descriptions and documentation. A lot of plugins have very minimal descriptions and documentation and leave the user alone. We want to change this.
All readme files are split into sections and

Tutorials | deliciousbrains.com | Mar. 16, 2016

AMP Up Your WordPress Site with Google’s Accelerated Mobile Pages

In the latest Delicious Brains article Jeff outlines AMP and how to use it in your WordPress site.

4 min read Tom Zsomborgi
Tutorials | kinsta.com | Jan. 14, 2016

Bandwidth Theft - How to Prevent Image Hotlinking in WordPress

In this article we’ll explain why hotlinking is bad and how you can prevent hotlinking on your WordPress site.

Bandwidth Theft - How to Prevent Image Hotlinking in WordPress

Tutorials | kinsta.com | Jan. 14, 2016

Hotlinking can be a huge drain of resources for the target website, not to mention it is technically theft. That said, many times the hotlinker isn’t aware that this is an issue. In this article I’ll explain why hotlinking is bad and how you can prevent hotlinking on your WordPress website.
What Is Image Hotlinking?
The concept of hotlinking is very simple. You find an image on the Internet somewhere and use the URL of the image directly on your site. This image will be displayed on your website but it will be served from the original location.
This is very convenient for the hotlinker but it’s actually theft as it is using the hotlinked site’s resources. It’s like me getting in my car and driving with gas I siphoned off my neighbour’s car.
This might not seem like a big deal, but it could generate a lot of extra costs for you. The Oatmeal is a great example. The Huffington Post hotlinked a cartoon of his which consisted of multiple images. Since we’re talking about a major publication this could incur a lot of extra costs for The Oatmeal.
In a classic Oatmeal move Matthew Inman – creator of The Oatmeal – replaced all of the hotlinked files with the following:
He also took care to replace

11 min read M Asif Rahman
Tutorials | codeable.io | Jun. 13, 2015

15 Cool and Useful WordPress Hacks that require no plugins

Few easy to implement hacks to gain some great feature.

15 Cool and Useful WordPress Hacks that require no plugins

Tutorials | codeable.io | Jun. 13, 2015

One of the things I love about WordPress is the easiness to empower it with (almost) endless features thanks to plugins. With 38000+ free plugins and an uncountable number of premium and custom ones, there’s a WordPress plugin for every need and budget. And if you look online to get WordPress tips, tricks or hacks, you'll surely end on a blog post that’s covering a list of (great) plugins that will provide you with what you were looking for. Actually, it's quite difficult to find a great list of WordPress tips, tricks and hacks that doesn't count a plugin in it. I know, they are powerful tools, but plugins aren't always required to enable a specific feature because WordPress alone can do cool things too.
So my question is: how many interesting features can be enabled on a WordPress website without installing a single plugin? I've put together a list of the best WordPress code snippets (or WordPress hacks, you choose) that you can play with right away and see for yourself you don't always need a plugin.
The following piece of codes can break your website, so please pay attention and make a backup before getting your hands dirty with them.
Let's start with one about branding: if you ever

Tutorials | kinsta.com | Aug. 29, 2014

A Beginner’s Guide to Website Speed Optimization

An in-depth guide to website speed optimization! If you have a couple of extra hours on your hands check it out and act on it! :)

9 min read WebDevStudios
Tutorials | webdevstudios.com | Apr. 6, 2015

How to Submit a Plugin to the Wordpress Repository

Ben guides you through the process of submitting a plugin to the WordPress repository.

How to Submit a Plugin to the Wordpress Repository

Tutorials | webdevstudios.com | Apr. 6, 2015

The WordPress.org Plugin Repository is the canonical location to find plugins for WordPress. There are many good reasons to add your plugin to this repository–the primary being that the built-in “Add New Plugin” search capabilities are linked directly to the WordPress.org repository. If your plugin is not in the WordPress.org repository, it will not be easily found by the majority of users, and with WordPress powering over 23% of the internet, you will be missing out on a large audience of potential users. Below, I provide an overview of the WordPress.org Plugin Repository, how you can start leveraging it with your own plugins, and, as a result, dramatically increase the potential reach of your audience.
What to know before you submit
WordPress.org has some guidelines on what can and cannot be in a plugin to get it approved. As long as those guidelines are followed plugins are typically approved withing a few days.
All plugins must have a license compatible with the GNU General Public License v2 (GPLv2) or a later version. If a plugin does not include a specific license, it will automatically fall under the parent project GPL license. If third-party libraries are included in the plugin

3 min read Donna Cavalier
Tutorials | donnafontenot.com | Feb. 27, 2016

WordPress HTTP:// to HTTPS:// Quick Start Guide

I jotted down a quick list to move 3 sites from HTTP to HTTPS today. All show green locks on every page now. Since it helped me, I figured I would list the steps in a blog post and share with everyone. So, I did. I also reference longer, more detailed posts, but the shorter version works better for me.

WordPress HTTP:// to HTTPS:// Quick Start Guide

Tutorials | donnafontenot.com | Feb. 27, 2016

This isn’t meant to be a comprehensive post on everything pertaining to moving a site from // to https://. Instead, this is more like the quick cheatsheet. This is basically the list of steps I use to move my small sites (all pages) from // to https://. There may be bumps in the road or special circumstances (especially for larger sites) that I don’t cover here. But if you just want the quick summary, this should work for you. If you have more than one site, I recommend you start by moving the smallest, least popular site. This gives you the ability to test things out without worrying too much. At the end of this WordPress HTTP:// TO HTTPS:// QUICK START GUIDE, I’ve provided a few resources that helped me think through this process. Note that none of them perfectly met my needs, so that’s why I wrote my own here. This is mostly a reminder for me! LOL. WordPress HTTP:// TO HTTPS:// QUICK START GUIDE
Have host install SSL certificate for your domain.
Go to https://yourdomain.com to see if it’s there, and if you have a green lock (you probably won’t have a green lock, so don’t worry at this point).
Add the following to your wp-config file.
define(‘FORCE_SSL_ADMIN’, true);
Go to https://yourdomain.com/wp-admin

Tutorials | deliciousbrains.com | Mar. 1, 2016

AWS Certifícate Manager: Using a Custom Domain with HTTPS and CloudFront

Amazon in thet same league that Let's Encrypt for his AWS Customer.

AWS Certifícate Manager: Using a Custom Domain with HTTPS and CloudFront

Tutorials | deliciousbrains.com | Mar. 1, 2016

As Ian alluded to a few weeks back, we’re big fans of Let’s Encrypt and rightly so! It’s one of the biggest things to happen in web security for a long time and will hopefully encourage the majority of sites to switch to HTTPS. A world where all connections are encrypted between a user’s browser and web server seemed like a pipe dream just a few years ago, but that’s no longer the case. Let’s Encrypt isn’t the only new Certificate Authority on the block. A few months ago Amazon also gained the same status. No surprises there! However, until the release of the AWS Certificate Manager there wasn’t a means to obtain certificates through Amazon. Similar to Let’s Encrypt, the AWS Certificate Manager greatly simplifies the process of generating SSL certificates for your CloudFront Distributions and Elastic Load Balancers. They’re also completely free and automatic renewals are taken care of out of the box.
Prior to the release of the AWS Certificate Manager, configuring CloudFront to use a custom domain over HTTPS was no easy feat. You had two options:
Configure SNI, which is overly complex and time consuming. It’s worth noting that some older browsers, namely IE 6 and 7 do not support SNI,

7 min read Matt Cromwell
Tutorials | joshpress.net | Sep. 14, 2016

Getting Started With Modern WordPress Development: What You Need - Josh Pollock

Josh delivers a succint overview of what you need to do modern WordPress development. Tuts like this should be required reading.

Getting Started With Modern WordPress Development: What You Need - Josh Pollock

Tutorials | joshpress.net | Sep. 14, 2016

I’m teaching a few workshops this month aimed at those looking to level up their WordPress development chops. It’s got me thinking a lot about what you need to do quality WordPress development. It’s a very subjective question, what software to use, what principles to value, what resources to learn from… So I wanted to share my thoughts on what is necessary for getting started. The list is less about software, and more about concepts because in the end, it’s about the wizard, not the wand.
Tools
You can write code in notepad and FTP it up to a shared host and hope for the best, but to do it right you need some basics tools. Here is my opinionated list. I’ve broken it down into “basics” and “important”. The first category is things you should have right away. The second list is important, but can probably wait.
Basics
A code editor is a specialized text editor designed for writing code. I like Atom as my simple code editor. It’s the application I use when I just need to open up a file, read it and maybe make a few changes.
An Integrated Development Environment (IDE) is more than a code editor. A good IDE provides everything

Tutorials | jeremypry.com | Sep. 3, 2014

WordPress Plugin Development with Git/GitHub

As git finds it way more and more into WordPress development, this tutorial will come in handy

WordPress Plugin Development with Git/GitHub

Tutorials | jeremypry.com | Sep. 3, 2014

Major props to Kaspars Dambis and the original tutorial that he wrote. I do things a bit differently, but that tutorial was absolutely instrumental in getting me up and running. Before We Begin
Note: This tutorial assumes that you’re setting up a new Plugin in the WordPress.org repository, and that you are starting with a GitHub repository. If you have an existing Plugin in the WordPress.org repository and merely want to switch to managing it with Git/GitHub, then please see this awesome tutorial instead.
When you first request that your Plugin be added to the WordPress.org repository, one of the required fields is a URL to your plugin. As described by the form:
must be a link to a ZIP file of the working plugin that includes a completed readme.txt
For this reason (and the fact that I prefer working with Git), I like to start my Plugin development on GitHub. However, this leads to a few extra steps in getting the Plugin set up on the WordPress.org repository. The purpose of this turorial is to document these steps as much for myself as for anyone else who wants to do something similar.
Here’s an overview of the steps we’re going to take:
Set up the Plugin on GitHub
If you already have

2 min read Matt
Tutorials | mattgeri.com | Dec. 16, 2015

Setting up SSL for your WordPress website with LetsEncrypt on Nginx

It took me 10 minutes to get Let's Encrypt SSL enabled on my WordPress blog. It's still early stage but this is a video tutorial for the devs on the bleeding edge :)

Setting up SSL for your WordPress website with LetsEncrypt on Nginx

Tutorials | mattgeri.com | Dec. 16, 2015

Setting up SSL for your website with LetsEncrypt on Nginx I’m really stoked right now! I’ve just enabled SSL on my website https://mattgeri.com. I did this using the brand new, free service called Let’s Encrypt. How cool is that?
Better yet, I documented the whole process in a video for you to learn from too. As I mentioned in the video, Let’s Encrypt is still very new and, specifically on Nginx, not 100% supported just yet, even though it’s quite easy to get working.
Here is the video. See below for the commands I run and configs I setup for copying and pasting in your own terminal window.
(If you like the video, make sure you subscribe to my newsletter! I share videos like this weekly and also other insights in to WordPress development)
Commands and Configs
Cloning the project to your server
Generating the certificate
1
./letsencrypt-auto certonly -a standalone -d mattgeri.com -d www.mattgeri.com
Nginx server domain config
listen 443 ssl spdy; listen [::]:443 ssl spdy; ssl_certificate /etc/letsencrypt/live/mattgeri.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mattgeri.com/privkey.pem; ssl_session_timeout 1d; ssl_session_cache shared:SSL:10m; ssl_protocols TLSv1.1 TLSv1.2;

Tutorials | rarst.net | Dec. 29, 2014

Asymmetrical WordPress loops

A while back, I had a question about the loop that I should've known, but like Rarst describes, I forgot the common sense answer. This is a good thing to remember about the default loop, which we probably all use nearly every day.

Asymmetrical WordPress loops

Tutorials | rarst.net | Dec. 29, 2014

While back Brian Krogsgard had tweeted a variation of quite common question. How to best handle WordPress loop, when you need to output posts differently or otherwise split it? If I have one template, and the default loop, but need to separate the output based on count… is rewind_posts the best option?
His idea wasn’t wrong, but indicative as typical jump to more complicated solution than it needs be. Loops are used so much they are treated as ritualistic monolithic snippet of code. Which they are actually not.
What is loop looping?
So if there was a championship in WordPress copy/paste the loop would probably take the first place confidently. This is how it usually looks and it doesn’t serve understanding well.
while ( have_posts() ) : the_post();

// 10 posts

endwhile;
Let’s adjust it a bit. It becomes more clear what is the block and what is inside the block.
while ( have_posts() ) {
the_post();

// 10 posts
}
So while we have posts we do… Something? What is that something. Let’s write it out. It doesn’t look precisely like that in source, I am paraphrasing what happens.
while ( have_posts() ) {
$post = $wp_query->next_post();
$wp_query->setup_postdata( $post

2 min read Matt Cromwell
Tutorials | tomjn.com | Jan. 23, 2017

Writing a WP REST API endpoint in 2 minutes

It's rare to get such a quick and easy tutorial on something that seems complicated but really isn't. Good read!

Writing a WP REST API endpoint in 2 minutes

Tutorials | tomjn.com | Jan. 23, 2017

I need to write a REST API endpoint, but lets assume we know nothing about REST APIs. The Task
My homepage has a box that contains a magical word, and I’m going to use the REST API to grab this word and display it on my site:
<div id="tomsword">... word goes here ...</div>
I’m going to need:
A word to use, I’ve chosen “moomins”
A REST API endpoint on my site to send the word from
Some Javascript to ask the API for the magic word
The Endpoint
This parts easy. REST API endpoints live at /wp-json, and they have a namespace so your endpoints don’t clash with those of other plugins. My endpoint is going to live at tomjn.com/wp-json/tomjn/v1/test.
When my endpoint is called, I want to return the word “moomins”, so I’ve prepared a function to do just that:
function tomjn_rest_test() {
return "moomins";
}
and I’ll register my endpoint, and tell WordPress what to do when it’s called like this:
add_action( 'rest_api_init', function () {
register_rest_route( 'tomjn/v1', '/test/', array(
'methods' => 'GET',
'callback' => 'tomjn_rest_test'