Author:
erics, October 21st, 2017
wordpress/wp-content/themes/yourTheme/single-yourCPTslug.php
|
add_action( 'genesis_before_entry_content', 'display_custom_fields' ); function display_custom_fields() { $jobTitle = get_field('_jobTitle') ?: '-'; print <<<EOT <br style="clear:both"/> <p>Job Title: $jobTitle</p> EOT; } // Genesis Loop genesis(); |
Categories: How-To's, Technology Tags: add_action, cpt, Custom, custom post type, genesis, genesis_before_entry_content, howto, Loop, meta, POST, post type, Single, Theme, tips, WordPress
|
No comments
Author:
erics, February 27th, 2015
|
#!/bin/bash for line in `cat file.txt`; do echo line: $line done |
|
#!/bin/bash for file in $( ls ); do echo filename: $file done |
|
#!/bin/bash for i in `seq 1 10`; do echo $i done |
Categories: How-To's, Technology Tags: bash, howto, Loop, tips
|
No comments
Author:
erics, May 15th, 2011
Coming from the Perl world, I wanted to emulate the following code in JavaScript:
|
my $myHash = { 'foo' => 'Hello', 'bar' => 'World', }; foreach my $myKey (keys %$myHash) { print $myKey,'=',$myHash->{$myKey}; } |
What I found is that JavaScript uses “Objects” to contain hash-style data:
|
// Define the hash object on the fly var myHash = { foo: "Hello", bar: "World" }; // loop through all keys for (var myKey in myHash) { alert(myKey + '=' + myHash[myKey]); } // access a key individually alert('foo=' + Hash.foo); alert('bar=' + Hash.bar); |
Also, one may use variables as key names by using the square-bracket notation, which evaluates variables first:
|
var myVar = 'test'; //These two lines are equivalent as long as myVar is 'test': myHash[myVar] = 'theValue'; myHash.test = 'theValue'; |
Categories: How-To's, Technology Tags: array, Hash, Iterate, javascript, Keys, Loop, Object, perl
|
No comments