Monday, November 2, 2015

Query Improvements in the Latest Versions of WordPress

Within the last year, much has been written about the improvements to the WordPress user interface: the most talked about change has been the improved writing experience.

But if you're a developer you'll be wanting to know less about that and more about what's changed under the hood. Here I'll demonstrate one of the most interesting changes for developers: improvements to certain types of queries.

The main changes are as follows:

  • Support for nested queries has been added for queries on post metadata, dates, and taxonomy terms.
  • Extra parameters have been added for querying comments.
  • And some bugs have been fixed too!

Let's have a look at the changes.

Nested Queries

In previous versions of WordPress, you could use an AND or OR statement to define queries for taxonomy terms, dates, and metadata. So for example, the following arguments will be used in a query on a recipe site which outputs quick breakfast recipes:

This looks for the 'speed' and 'meal' taxonomies and outputs posts with the 'quick' and 'breakfast' terms respectively.

But what if you wanted to write a more complex query? Let's say you wanted quick recipes for breakfast and slow recipes for lunch (maybe for someone who wants to get breakfast done quickly so they have more time to cook lunch!). You don't want to use a simple AND statement to join all the elements of your query, since then you would get slow recipes for breakfast and lunch, for example. And you don't want to use an OR statement linking all the terms, as you'll get all manner of recipes which only have one of the queried terms along with other ones you want to filter out.

The good news is that now you can do this. To query quick recipes for breakfast and slow recipes for lunch, you'd use the following:

Here I've used two nested arrays:

  • The outer array uses OR, because we're looking for posts which are either quick breakfast recipes or slow lunch recipes.
  • The first nested array looks for posts which are quick breakfast recipes, using AND because you want the post to have both terms.
  • The second nested array looks for slow lunch recipes, again using AND.

Of course you could vary your queries to include multiple taxonomy terms and values, and get as complex as you need.

Applying Nested Queries: Taxonomy Terms, Metadata, and Dates

The example I've given above uses taxonomy terms, but this feature has also been added to date and metadata queries. Metadata is potentially where things could get interesting, as you have the scope for so many values.

The syntax works in exactly the same way for date and metadata queries. For meta queries you replace tax_query with meta_query and use 'key' and 'value' as the parameters. For date queries you replace tax_query with date_query and use the date parameters provided in the WordPress Codex.

Comment Parameters

To query comments, you use the WP_Comment_Query class in place of the more commonly used WP_Query class. This class has had eight new parameters added to it:

  • 'author__in': identify comment author (or an array of authors)
  • 'author__not_in': identify comments not by a certain author (or array of authors)
  • 'post_author__in': identify author (or array of authors) of the post the comment was made on
  • 'post_author__not_in': exclude comments made on posts written by particular author or array of authors
  • 'comment__in': comments with a certain ID or array of IDs
  • 'comment__not_in': exclude comments with a certain ID or array of IDs
  • 'post__in': comments made on a post or array of posts (using the post ID)
  • 'post__not_in': exclude comments made on a post or array of posts (using the post ID)

The values used for these are the author ID, comment ID or post ID as appropriate.

Note that the WP_Comment_Query class now supports nested queries as well.

Bug Fixes

There have also been a couple of bug fixes which you might find helpful:

  • A bug that caused queries to fail when a date_query was used along with a tax_query or meta_query has been fixed.
  • When ‘orderby' => 'meta_value’ was used when passing a 'meta_query' with the OR relation  in WP_Query, this used to break the query. This has been fixed.

If you want the lowdown on all the details, you can find it on the make WordPress core site.

Summary

These improvements to queries take WordPress a step further to full CMS capability. The ability to use nested queries means that you can output content in much more flexible and complex ways. It will be interesting to see how people use them!


by Rachel McCollin via Tuts+ Code

Introducing our Premium One Page Website Review Service

opl-smallAfter a successful Private Beta we have officially launched a new service that audits the design/code of your One Page website. The feedback really has been awesome so far!

The Premium Review consists of a full design and code audit of your One Page website by the One Page Love team. This comprehensive review takes screenshots of your One Pager pointing out design and code issues including suggestions for your website.

The review is also presented in a responsive website that you can share with your team with a secret URL. Neato!


The full review covers 6 main areas:

1. First Impression

This section consists of our immediate thoughts upon first review without reading the submitted build notes. These comments often pick up issues with the overall concept and flow of the website. Often a team has been working on a website so long they forget that it needs to be much clearer to new users.

2. User Experience (UX)

“User experience” encompasses all aspects of the end-user’s interaction with the One Page website. UX feedback covers:

  • Language tone
  • Trust
  • Transparency
  • Navigation and browsing
  • Consistency

3. Design

These design notes are suggestions that come from a subjective point of view. Design feedback covers:

  • Logo
  • Branding
  • Responsive adaption
  • Spacing
  • and more

4. Code

These code notes are suggestions based on reports from online services but also include experienced suggestions for good practice. Code feedback covers:

  • PageSpeed Insights
  • Source Code inspection
  • Search Engine Optimization
  • Heading hierarchies
  • and more

5. Grammar

Bad grammar and spelling result in terrible first impressions and decrease conversions. We point out the errors.

6. Final Thoughts

Suggestions on ways to improve the overall website concept delivery. This could include simplifying the website or even adding more elements to increase trust.


Launch Special 20% Off Coupon

For November only, use the coupon NovemberLove to get $20 off the Premium Review Service.


by Rob Hope via One Page Love

How to Create a Facebook Video Ad That Moves People to Action

ak-facebook-video-ad-560

Are you using Facebook video ads for your business? Want to improve your conversions? Well-structured video ads command viewers’ attention and prompt them to take action. In this article you’ll discover five steps to crafting the perfect Facebook video ad. Why Facebook Video Ads? Facebook’s head of ad product Ted Zagat recently said that a […]

This post How to Create a Facebook Video Ad That Moves People to Action first appeared on Social Media Examiner.
Social Media Examiner - Your Guide to the Social Media Jungle


by Anja Kicken via Social Media Examiner

When to Use rel="nofollow"

Assigning the rel="nofollow" attribute to a link informs search engines that the link is commercial in nature, or that it’s a link you don’t endorse.

Links that have the the rel="nofollow" attribute are often called nofollow links.

Just so we’re on the same page, here’s an example of a link that uses the rel="nofollow" attribute:

<a rel="nofollow" href="http://example.com">nofollow link</a>

The concept behind nofollow links came about in 2005, as a way of discouraging comment spam in blogs.

You might already know this if you’re familiar with SEO: One of the factors search engines take into account when ranking a website is the number of other websites linking to it (referred to as the site’s inbound links).

If there are many links from other sites pointing to your site, and those other sites are reputable, then there’s a good chance your site is also reputable.

To artificially boost their clients’ search engine rankings, spammers will try to place as many links as they can on other websites. An easy target for spammers are the "comments" sections of reputable blogs.

To help address the spam issue, the rel="nofollow" attribute was introduced.

The thinking went like this: If comment spammers didn’t get credit for their nofollow links, then they’d be less likely to waste their time posting those links on blogs.

Today, the purpose of rel="nofollow" has evolved slightly. It’s now also supposed to be used on links that are commercial/for-profit in nature. Links that fall into this category are:

  • paid links
  • banner ads
  • sponsored content
  • text link ads
  • affiliate links

The rel="nofollow" attribute started off as a microformat. However, the HTML attribute is now in the latest W3C HTML specification, in section 4.8.4.7 Link type “nofollow”.

Here’s how the attribute should be used in accordance to specs:

The nofollow keyword indicates that the link is not endorsed by the original author or publisher of the page, or that the link to the referenced document was included primarily because of a commercial relationship between people affiliated with the two pages.4.8 Links — HTML5

So, When Should You Use rel="nofollow"?

Based on the specs, the two cases in which you should use rel="nofollow" are:

  1. When the link is something you don’t/can’t endorse
  2. When the link is primarily commercial in nature

Let’s talk about these two cases.

Links You Don’t Endorse

A typical example of a link you can’t endorse is one that was placed on your site by someone else.

For example, if you have a blog, the comments on your blog are posted by your readers. Those comments often contain links. It’s not practical to review each and every link commenters post on your site. Using the rel="nofollow" attribute in the "comments" section of your blog essentially tells search engines, “Hey, I haven’t reviewed, and therefore can’t vouch for, any of the links you find here.”

That’s why, by default, WordPress (1.5 and above) automatically sets the rel="nofollow" attribute on user-generated links in the "comments" sections of WordPress-powered sites.

Wikipedia uses the rel="nofollow" attribute on all external links. Wikipedia can be edited by anyone. And because of the sheer volume of content on the site, it’s not practical for Wikipedia to verify, review, and endorse each and every external link posted on their site. So Wikipedia decided to categorically assign the rel="nofollow" attribute on all external links, much like how WordPress categorically assigns the attribute on all external links it finds in the "comments" section.

On Wikipedia, notice how an external link that goes to w3.org — which you and I know is a pretty reputable site — is a nofollow link.

External links in Wikipedia have rel="nofollow"attributes.With Chrome DevTools, we can see that external links in Wikipedia have rel="nofollow" attributes.

On Reddit, new link submissions are nofollow.

On Reddit, new link submissions are nofollow.

What’s interesting with Reddit’s implementation is that when an external link has been voted to the front page of the site, its rel="nofollow" attribute is removed.

On Reddit, front page external links do not have a rel="nofollow" attribute.

Reddit’s system of assigning rel="nofollow" attributes is clever because it’s democratic. Reddit makes the hypothesis that if a submitted link gets the required votes needed to propel itself to the site’s front page, then it must mean enough people have reviewed the trustworthiness of the link, and thus the link’s rel="nofollow" attribute can be safely dropped.

Links That Are Commercial in Nature (Paid Links)

When a link exists on your site primarily for profit, it should be assigned a rel="nofollow" attribute.

Simply put: If you publish paid advertisements on your site — banner ads, text links, sponsored content, affiliate links, etc. — the links going to your advertisers’ sites should be nofollow.

This is one way to discourage any site from trying to buy its way into better search rankings by paying other sites for links.

Why Use rel="nofollow"?

The rel="nofollow" attribute benefits third-party services most. Search engines, for example, can use the information we give them about links on our site as a clue that certain links might be low-quality, or commercial in nature, or both. They can then use this knowledge to improve the quality of their search results for their users.

So what’s in it for us?

By disclosing which links on our site have been paid for and which ones haven’t been reviewed, we can reduce the chances of search engines penalizing our site for publishing low-quality external links.

It’s reasonable to assume that by diligently assigning the rel="nofollow" attribute on our unverified, untrusted, and paid links we can improve our website’s SEO, and our website’s trustworthiness as a source of quality content.

Learn More About Nofollow Links

Read Next

10 SEO Tips to Remember When Building Your Site

User-Friendly SEO

What Potential Impact Can HTML5 Have on SEO?

Fine-Tuning WordPress for SEO

Jacob Gube is the founder of Six Revisions. He’s a front-end developer. Connect with him on Twitter and Facebook.

The post When to Use rel="nofollow" appeared first on Six Revisions.


by Jacob Gube via Six Revisions

8 Ways to Generate Leads With Your Blog

mh-generate-leads-560

Is your blog generating leads for your business? Are you looking for ideas? Offering a suitable and relevant reward in return for people’s contact information is a great way to generate business leads. In this article you’ll discover eight ways to generate leads with your blog. Why Lead Generators? A lead generator (or lead magnet) is something […]

This post 8 Ways to Generate Leads With Your Blog first appeared on Social Media Examiner.
Social Media Examiner - Your Guide to the Social Media Jungle


by Marcus Ho via Social Media Examiner

Viens-là

Viens-là is an independent digital agency dedicated to brand universe creation, web-site and high-value mobile application design.
by via Awwwards - Sites of the day

LHBZR

LHBZR

Unique and minimal One Pager for Brazilian developer 'Luis Henrique Bizarro' featuring a background visualiser that sync's with a pumping soundtrack. (Sound warning)

by Rob Hope via One Page Love