• Resolved theronin

    (@theronin)


    I’m outputting an echo statement if a conditional check is matched. In this echo statement I have an unordered list

      like this:

      <?php
      $parent_title = get_the_title($post->post_parent);
      if ($parent_title == 'Directors Biographies') {
      echo
      	'<ul id="biogs">
      		<li class="active"><a href="#">Director 1</a></li>
      		<li><a href="#">Director 2</a></li>
      		<li><a href="#">Director 3</a></li>
      		<li><a href="#">Director 4</a></li>
      		<li><a href="#">Director 5</a></li>
      	</ul>';
      }
      ?>

      However where the #’s currently are, I need to insert the following php:

      <?php bloginfo('siteurl'); ?>/company/biographies/index.php?page_id=71

      How can I insert this php block inside another php block without it breaking?

      Or, is there an alternative to grabbing the site url? I’ve tried /index.php?page_id=71 but because my WordPress installation is in a directory off the root it leaves it out.

      Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Example:

    <li><a href="'. get_permalink(71).'">Director 2</a></li>

    71 would be the ID for the page or post, just do the same for each…

    Thread Starter theronin

    (@theronin)

    Ahh, much simpler than I thought. I knew there would probably be a better way of doing it!

    By the way what is the dot (.) notation for before and after the template tag?

    Thanks for your help.

    Thread Starter theronin

    (@theronin)

    Ok, I see, just general PHP string concatenation.

    Thanks again.

    Yes that’s right, just concatenating the echo to include a function call, in this case get_permalink which just returns a value …

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘PHP inside PHP echo’ is closed to new replies.