simple syntax issue of hardcoded value vs GET variable
-
When I hardcode the value in, like I’ve done below. “Healthcare”, “Technology”, etc. My posts show up. However, this needs to be dynamically done via the URL GET Variable.
$args = array( 'post_type' => 'earnings', // use to be stock 'posts_per_page' => 1, 'offset' => $_GET['offset'], 'meta_query' => array( array( 'key' => 'sector', 'value' => 'Healthcare' )) );
However, when I do this.
$args = array( 'post_type' => 'earnings', // use to be stock 'posts_per_page' => 1, 'offset' => $_GET['offset'], 'meta_query' => array( array( 'key' => 'sector', 'value' => $_GET['sector'], 'compare' => '=' )) );
The code busts and I do not get any results. I’ve tried setting
$_GET[‘sector’] to a variable first, and then doing
'value' => $variable
but that didn’t work either, and I have echoed that variable out to the screen and it indeed is “Healthcare”.I’m not sure what I’m doing wrong, could anyone lend a helping hand?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘simple syntax issue of hardcoded value vs GET variable’ is closed to new replies.