Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8484289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:20:27+00:00 2026-06-10T20:20:27+00:00

I am having issues with my code. I am pretty certain that it is

  • 0

I am having issues with my code. I am pretty certain that it is related to quotations. Let me demonstrate.

This works fine:

<?php if ( $is_latest_post ) echo '
hello world
'; ?>

This doesn’t work:

<?php if ( $is_latest_post ) echo '
<a class="recent<?php $category = get_the_category(); echo $category[0]->category_nicename; ?>" href="<?php bloginfo('url'); ?>/<?php echo $category[0]->category_nicename; ?>"><?php echo $category[0]->cat_name; ?></a>
'; ?>

Why doesn’t it work? What can I change to make it function? The a class part of the code works perfectly outside the if ( $is_latest_post ) statement. Appreciate that I have only just started learning coding with PHP.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T20:20:28+00:00Added an answer on June 10, 2026 at 8:20 pm

    when you encapsulate strings in single quotes, it treats that string as a literal. PHP will not parse the code you have in that string.

    What you need is concatenation. The dot operator . lets you mash several strings together.

    <?
    if ( $is_latest_post ) {
        $category = get_the_category();
        echo '
        <a class="recent' . $category[0]->category_nicename . '" href="' . bloginfo('url') . '/'. $category[0]->category_nicename . '">' . $category[0]->cat_name . '</a>';
    }
    ?>
    

    You can concatenate arbitrarily many things together.

    <?
        $a = 1;
        $b = 2.0;
        $c = 'string';
        $d = function_call();
    
        $string = $a . $b . 'random text' . $c . $d;
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having some issues with a jQuery AJAX call. My code works fine when
I'm having issues in my code due to the multiple representations that a same
I am having some issues with a code that is occasionally and sporadically throwing
I'm having issues with a bit of code that I am writing in C#.
I'm having some issues with my code. This is probably due to some design
I'm having some issues with some jQuery code, and I'm hoping and thinking that
So I'm having pretty much exactly the problem described here: http://code.google.com/p/android/issues/detail?id=6191 and until the
Im having issues with my code, its returning an error that says... 2011-12-24 22:52:36.280
again. Right now I'm having issues with some pretty basic functionality in PHP. I
I'm trying to learn C++ currently, but I'm having issues with the code below.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.