WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm not sure whats wrong with this line. Have I place this incorrectly? How do I get it to recognize the $yourcat->slug;

 $cat = get_query_var('cat');
 $yourcat = get_category ($cat);
 $uri = $_SERVER['REQUEST_URI'];
 if (($uri == '/category/$yourcat->slug;') { 
share|improve this question

your syntax is wrong change the single quotation mark to a double quotation mark and remove the semicolom on this line:

if (($uri == '/category/$yourcat->slug;') { 

it should become:

if (($uri == "/category/$yourcat->slug") {
share|improve this answer

AND you can surround the variable with curly brackets

if (($uri == "/category/{$yourcat->slug}") {

when you use single quotes, php does not look in the string for variables to replace. when you use double quotes it does. But in some cases there can be confusion such as this case. So when you do object reference like this, it's best to use the curly braces to explicitly say this is a variable that should be replaced.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.