What does the Global Variable $s represent?

It’s not a global variable; in fact it’s not a variable at all. It’s just placeholder within the sprintf() function. Take a look at the sprintf PHP function documentation. In the example you cite, the author is using the ‘argument swapping’ placeholder syntax: %n$t where %n is the placeholder number that corresponds to the argument … Read more

persist a variable set in header.php all the way down to footer.php

You’d have to declare it first above those includes and globalize it within header or footer before getting or setting the value. however- in the specific context you’re speaking of- getting a custom field value, it’s only retrieved from the database on the first call, then cached, so subsequent calls won’t hit the database again.

How to get CGI variables?

First off, these aren’t CGI variables, they’re query string arguments. WordPress, by default, will remove any query arguments that it doesn’t recognize. So you need to register them with WordPress and then pull them back out of the query. First, add your new query variable: function wpa_48528_vars( $vars ) { $vars[] = ‘filter’; return $vars; … Read more

category__not_in and id values from variable

get_category_by_slug() returns a category object or FALSE: $cat1 = get_category_by_slug( ‘cata’ ); print ‘<pre>’ . htmlspecialchars( print_r( $cat1, TRUE ) ) . ‘</pre>’; Result: stdClass Object ( [term_id] => 3 [name] => Cat A [slug] => cata [term_group] => 0 [term_taxonomy_id] => 3 [taxonomy] => category category__not_in and id values from variable => [parent] => … Read more

Passing a variable from a FOREACH loop in a link

This is more of a basic PHP question, but still it’s somewhat important. Inside your foreach loop, $category is a locally-defined variable. That’s to say, it only exists inside the foreach loop. So if you have foreach ( $categories as $category ) { // You can use $category all you want in here } // … Read more

Apply class to every third list item? [duplicate]

add a simple counter and conditional check: $pages = get_pages(‘child_of=10’); $counter = 1; if ($pages) { echo ‘<ul class=”projectthumbs”>’; foreach ($pages as $page) { if ($counter == 3){ $class=” class=”YOUR_CLASS””; $counter = 1 }else{ $class=””; $counter = $counter +1; } echo ‘<li’.$class.’><a href=”‘.get_permalink($page->ID).'”>’; echo get_the_post_thumbnail($page->ID); echo ‘<span class=”projectthumbtitle”>’; echo get_the_title($page->ID); echo ‘</span>’; echo ‘</a></li>’; } … Read more

Adding numbers inside a span tag in nav menu [closed]

$(“#top .menu ul li”).each(function(i, el) { $(this).children(‘a’).prepend(“<span>” + (i+1) + “</span>”); }); or much better $(“#top2 .menu ul li”).each(function() { var $this = $(this); $this.children(‘a’).prepend(“<span>” + ($this.index()+1) + “</span>”); }); check this out for the difference… http://jsfiddle.net/reigel/aAYCt/

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)