Posts

Showing posts with the label Loop

Foreach in Google Apps Script

In Google Apps Script, you can do the foreach loop as the following example:  var headers = ["super", "genius", "awesome"];  for each (var header in headers) {        Logger.log(header);  }

Foreach in javascript

If you wanna use foreach to loop through an array (list) in javascript, do as the following example: var myarray = ["genius", "super", "god"]; myarray. forEach (function(value, index){     console.log(index + ": " + value); }); the result will be: 0: genius 1: super 2: god Tested in Chrome 45.

Hide categories from your WordPress homepage

Using the WordPress's Loop  , pre_get_posts , you can hide certain categories from your homepage. In your theme's functions.php , add these following: function hide_category_home( $query ) { if ( $query->is_home ) { $query->set( 'cat', '-5, -34' ); } return $query; } add_filter( 'pre_get_posts', 'hide_category_home' ); 5 and 34 are IDs of categories you want to hide. Cool!