Wednesday, October 7, 2015

This Week in Mobile Web Development (#77)

Read this on the Web

Mobile Web Weekly October 7, 2015   #77
Brian Rinaldi recommends
Takeaways From Mobile Web Behavior — Richard Howe looks at what we can learn from the ways in which users interact with websites on mobile.
Smashing Magazine
Holly Schinsky recommends
Learn Ionic in your Living Room — A set of resources to learn Ionic at home including tutorials, twitter groups, online courses and a new site from Ionic called Appcamp with a set of free courses for learning mobile web dev.
The Official Ionic Blog
Brian Rinaldi recommends
The State of JS Performance on Android in 2015 is... Poor — The creator of the popular Discourse forum software (which heavily uses Ember) finds Android isn’t keeping up with iOS’s JavaScript performance leaps.
Jeff Atwood
This issue is sponsored by Telerik
Interested in building mobile apps? — Develop iOS and Android mobile apps using HTML5, CSS and JavaScript.
Telerik

Peter Cooper recommends
Mobile Browser Traffic Is 2X Bigger Than App Traffic, and Growing Faster
VentureBeat
Brian Rinaldi recommends
The Cost of Mobile Ads on 50 News Websites — Visualizations of the data collected by the New York Times regarding the performance of mobile web sites when using ad blockers.
NY Times
Holly Schinsky recommends
Coding for the Big Screen with the Apple TVOS SDK — How to use the Apple tvOS SDK to create apps for the new Apple TV and publish them to the App Store.
SitePoint
Brian Rinaldi recommends
A new Device Adaptation spec — PPK suggests the changes he thinks are necessary to the W3C Device Adaptation spec.
QuirksBlog
Brian Rinaldi recommends
Using Responsive Images (Now) — Chen Hui Jing talks shows the way responsive images can serve images of different quality or art direction depending on the user’s viewport.
A List Apart
Holly Schinsky recommends
Getting Visual Studio Cordova Tooling Working with the Ionic Framework — How to set up Visual Studio 2015 for mobile development with Cordova and Ionic.
Justin James
Brian Rinaldi recommends
Introducing the U.S. Web Design Standards — The U.S. Web Design Standards are the U.S. government’s very own set of common UI components and visual styles for websites.
Mollie Ruskin, Carolyn Dew, Maya Benari, and Colin MacArthur
Brian Rinaldi recommends
Putting Mobile Ad Blockers to the Test — The NYTimes tested 50 news sites with and without ad blockers and found that they improved page performance significantly though they had limited impact on battery life.
NY Times
Peter Cooper recommends
Mobile Web Performance using WebPageTest and HTTPArchive
Doug Sillars
Holly Schinsky recommends
Thali Open Source Platform for Peer to Peer Data Sharing — Thali is a new open source project for creating a peer to peer network for data sharing to allow for refined control over your data.
Thali Project
Brian Rinaldi recommends
Ionic 1.6.5 and updates to Services — What’s new in the latest version of Ionic and Ionic Platform services,
Raymond Camden
Brian Rinaldi recommends
A Master Detail layout for Ionic — How to use Ionic to build a master/detail responsive layout.
Scott Logic
Holly Schinsky recommends
Angular iOS9 UIWebView Patch — A patch to work around an issue with the iOS9 UIWebView causing infinite digest errors in Angular.
GitHub - Igor Minar
Job listing
Want to spend less time job searching? Apply to the best startups in 60 seconds. — If you’re accepted, startup decision-makers will email you as soon as next Monday. You decide where to interview and where to work. Now open in SF, NYC, and remote. Join the Underdog.io platform today!
Underdog.io

Curated by Brian Rinaldi and Holly Schinsky for Cooper Press.
Cooper Press is located at Office 30, Fairfield Enterprise Centre, Louth, LN11 0LS, UK
Update your email address
or stop receiving MWW here


by via Mobile Web Weekly

PostCSS Quickstart Guide: Exploring Plugins

This Week's HTML5 and Browser Technology News (Issue 209)


Read this e-mail on the Web
HTML 5 Weekly
Issue 209 — October 7, 2015
Addy Osmani
A link to a detailed, easy to navigate slide-deck, but if you have the time, there’s a video of the talk too (47 minutes).


SitePoint
When you use ‘em’, the sizes are relative to the font size of the parent element. ‘rem’, on the other hand, is always based on the ‘root’ element of a document. All you could want to know about using them is here.


Paul Lewis
Paul reflects on the issues of building a podcast player app using Web technologies when cross-origin resource sharing (CORS) issues make it difficult to fetch third party resources without proxying.


Frontend Masters  Sponsored
14-day $5 trial of front-end training with industry legends. Upgrade for 38% off our original price, or cancel in 10 seconds. Until September 10th at midnight ONLY. See page for details.

Frontend Masters

W3C
The HTML Working Group has published a Proposed Recommendation of W3C DOM4, the latest version of the platform-neutral model for events and node trees.


W3C
Describes a method of combining multiple DOM trees into one hierarchy and how these trees interact with each other within a document.


Louis Lazaris
Development of the ECMAScript standard (the spec behind JavaScript) moved to GitHub recently and adopted its own HTML-esque markup format.


Martin Anderson
Reflections on an academic paper which looks at the role of technologies like WebRTC in covert communications.


David Scott Lyons
A cool code-driven Web-based slidedeck walking through some basic examples of 3D rendering on the Web.


Jobs

  • Senior UI/UX Designer in Denver, ColoradoAre you smart? Do you want to lead the User Interface rewrite of our award-winning BI product in collaboration with Zurb? Do you consider yourself an innovative leader as well as a team-player? If so then you may be a great fit for the Sr UI/UX Designer position at Motivity. Motivity Solutions (Mortgage Business Intelligence)
  • Give back to the developer community-apply to teach today.Actively seeking web developers to join our tight knit family of passionate teachers and earn royalties.  Pluralsight

In brief

Curated by Peter Cooper and published by Cooper Press.
Want to post a job? E-mail us or use our self-serve system.

Unsubscribe : Change email address : Read this issue on the Web

Published by Cooper Press Ltd. Office 30, Lincoln Way, Louth, LN11 0LS, UK


by via HTML5 Weekly

WP_Query Arguments: Status, Order and Pagination

In this part of the series on Mastering WP_Query, you'll learn about some of the arguments you can use with the WP_Query class, namely those for:

  • status
  • order
  • pagination

You can use these arguments to fetch scheduled posts from the database, to query attachments, to amend the way posts are ordered and what they're ordered by, to specify how many posts are displayed, and much more

But before you can do this, you need to understand how arguments work in WP_Query.

A Recap on How Arguments Work in WP_Query

Before we start, let's have a quick recap on how arguments work in WP_Query. When you code WP_Query in your themes or plugins, you need to include four main elements:

  • the arguments for the query, using parameters which will be covered in this tutorial
  • the query itself
  • the loop
  • finishing off: closing if and while tags and resetting post data

In practice this will look something like the following:

The arguments are what tells WordPress what data to fetch from the database and it's those that I'll cover here. So all we're focusing on here is the first part of the code:

As you can see, the arguments are contained in an array. You'll learn how to code them as you work through this tutorial.

Coding Your Arguments

There is a specific way to code the arguments in the array, which is as follows:

You must enclose the parameters and their values in single quotation marks, use => between them, and separate them with a comma. If you get this wrong, WordPress may not add all of your arguments to the query or you may get a white screen.

Status Parameters

As you'll know if you've ever converted a post's status from Draft to Published, or maybe put it in the trash, WordPress assigns a status to each post. You can use the post_status parameter to query for posts with one or more statuses.

The arguments available are:

  • publish: A published post or page.
  • pending: Post is pending review.
  • draft: A post in draft status.
  • auto-draft: A newly created post, with no content.
  • future: A post to publish in the future.
  • private: Not visible to users who are not logged in.
  • inherit: A revision.
  • trash: Post is in trashbin.
  • any: Retrieves any status except those from post statuses with 'exclude_from_search' set to true (i.e. trash and auto-draft).

If you don't specify a status in your query arguments, WordPress will default to publish; if the current user is logged in, it will also include posts with a status of private. If you run a query in the admin pages, WordPress will also include the protected statuses, which are futuredraft and pending by default.

So let's say that you're running an events site and you're using a custom post type of event, using the publication date as the date that the event takes place. By default WordPress won't display any events that haven't happened yet: although you've scheduled them, their scheduled date is in the future so their post status is future.

To get around this you simply use these arguments:

This will only display those events which haven't happened yet, as those will have the publish status. But if you also want to display events which have happened, you can use an array of post statuses to include more than one:

The post_status parameter is essential when you're querying for attachments. This is because they have a status of inherit, not publish. So to query for all attachments, you'd use this:

Alternatively you could replace inherit with any which would have the same effect.

Order Parameters

There are two parameters you use to order posts retrieved by WP_Query: order and orderby. As you'd expect, order defines the order in which posts will be output in the loop, and orderby defines which field in the database they'll be sorted by.

Let's start by looking at the arguments for order.

The order Parameter

There are just two arguments you can use for this:

  • ASC: ascending order from lowest to highest values (1, 2, 3; a, b, c).
  • DESC: descending order from highest to lowest values (3, 2, 1; c, b, a).

These are fairly self-explanatory. If you don't include an argument for order, WordPress will default to DESC.

The orderby Parameter

You can sort your posts by a range of fields:

  • none: No order (available with Version 2.8).
  • ID: Order by post id. Note the capitalization.
  • author: Order by author.
  • title: Order by title.
  • name: Order by post slug.
  • type: Order by post type.
  • date: Order by date.
  • modified: Order by last modified date.
  • parent: Order by post/page parent id.
  • rand: Random order.
  • comment_count: Order by number of comments.
  • menu_order: Order by Page Order. Used most often for Pages (using the value you add to the metabox in the Edit Page screen) and for Attachments (using the integer fields in the Insert / Upload Media Gallery dialog), but could be used for any post type with menu_order enabled.
  • meta_value: Sort by the value for a meta key (or custom field). This only works if you also include a meta_key parameter in your arguments. Meta values are sorted alphabetically and not numerically (so 34 will come before 4, for example). 
  • meta_value_num: Order by numeric meta value. As with meta_value, you must also include a meta_key argument in your query.
  • post__in: Preserve post ID order given in the post__in array.

The default is date, i.e. the date a post was published.

So for example if you want to sort your posts by title in ascending order, you would use these arguments:

Ordering by Multiple Fields

You don't have to stick to just one field to sort your posts by. To sort by multiple fields, you use an array with the orderby parameter and (optionally) with the order parameter if you want to sort each field in a different order.

So let's say you have a ratings custom field which you want to use for sorting in an e-commerce site. You could sort by rating and then title, both in ascending order, this way:

Note that I've included the meta_key argument to let WordPress know which custom field I'm using. You do this because of the way WordPress stores post metadata: not in the wp_posts table, but in the wp_postmeta table.

But what if you wanted to order by rating in descending order and then title in ascending order? You simply use another array:

You could also sort by multiple fields when not using post metadata, for example to sort by post type and then date:

This would sort by post type in ascending order and then within each post type, by date in descending order.

Pagination Parameters

The next set of parameters we come to are for pagination. These help you define how many posts will be queried and how pagination will work when they are output.

The available parameters are:

  • nopaging (boolean): Show all posts or use pagination. The default is 'false', i.e. use pagination.
  • posts_per_page (int): Number of posts to show per page.
  • posts_per_archive_page (int): Number of posts to show per page—on archive pages only.
  • offset (int): Number of posts to displace or pass over.
  • paged (int): The page in the archive which posts are shown from.
  • page (int): Number of pages for a static front page. Show the posts that would normally show up just on page X of a Static Front Page.
  • ignore_sticky_posts (boolean): Ignore post stickiness—defaults to false.

Let's take a look at some examples. 

Number of Posts and Offsetting Posts

For example, to display the five most recent posts:

Or to display five recent posts excluding the most recent one:

Note that although you're fetching posts from the most recent six posts in the database, you still use 'posts_per_page' => '5' as that's the number of posts which will be output.

Taking this a bit further, you can write two queries: one to display the most recent post and a second to display ten more posts excluding that post:

You can also use posts_per_page to display all posts:

Sticky Posts

Normally your sticky posts will show up first in any query: if you want to override this, use ignore_sticky_posts:

The above arguments will return the most recent five posts regardless of whether they are sticky or not.

Note that if you want to display just sticky posts, you'll need to use the get_option() function and the post__in argument as follows:

The above would display the last five sticky posts: if there are less than five (e.g. three) sticky posts, it won't display non-sticky posts but just the most recent three sticky posts.

Pagination in Archives

As well as defining how many posts are fetched from the database, you can also use pagination parameters to define how the resulting posts will be paginated on archive and search pages.

So for example on an archive page you could use this code to display 20 posts per page in the archive:

Note: the posts_per_archive_page argument will override posts_per_page.

You can also choose to output just the pages which would appear on a given page in paginated pages. So for example if you wanted to show the 20 posts that would appear on the third page in the example above, you'd use this:

An alternative way to query the same posts would be to use the offset argument:

This skips the first 40 posts (which would be on the first two archive pages) and fetches the next 20 posts (which would be on the third archive page. One of the things I love about WordPress is how it so often gives you more than one way to achieve something!

You can also turn pagination off altogether, to ensure that all posts will show on the same page:

Summary

The WP_Query class gives you plenty of flexibility when it comes to determining how many posts you want to query, what order you want to display them in, and what status of post you want to show.

Some of these arguments are essential for querying certain kinds of post (for example 'post_status' => 'inherited' for attachments), while others simply give you more control over the way your queries run.

By using these parameters you can create custom queries that do a lot more than simply outputting the most recent published posts.


by Rachel McCollin via Tuts+ Code

Deutser

We Cant Stop Thinking and RSQ partnered with Deutser to create a highly sophisticated website. The site features a WebGL system that generates floating particles in specific shapes.
by via Awwwards - Sites of the day

5 Psychology Tips to Improve Your Social Media Posts

wh-psych-tips-improve-social-posts-560

Are you struggling to create social media engagement? Do you want tips to improve your posts? To get more social media engagement, you need to tailor your content to appeal to your audience on an emotional level. In this article you’ll discover five psychology tips to improve engagement on your social media posts. #1: Images Speak to […]

This post 5 Psychology Tips to Improve Your Social Media Posts first appeared on Social Media Examiner.
Social Media Examiner - Your Guide to the Social Media Jungle


by Wade Harman via Social Media Examiner

Advisors Excel “It’s Your Birthday Song”

Fun One Pager focused around a central "Happy Birthday" video that is sent to the individual investors of 'Advisors Excel' on their birthday.

by Rob Hope via One Page Love