SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot w1nk5's Avatar
    Join Date
    Aug 2009
    Location
    Ontario, Canada
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Concatenate WP Function in String

    I am trying to create a div with some content at the top of my wordpress blog ONLY if the user is on the first page of posts.

    This is what I have:

    Code:
    <?php $pagenum = $wp_query->query_vars; ?>
    <?php $pagenum = $pagenum['paged']; ?>
    
    <?php 			
       if($pagenum == 0) {
          echo '<div id="bio">';
          echo '<img src="' . bloginfo("template_directory") . '/img/gerry.jpg" />';
          echo '</div>';
    } ?>
    For some reason it is returning a link to the template directory.

    The problem seems to be with the line: echo '<img src="' . bloginfo("template_directory") . '/img/gerry.jpg" />';

    Any ideas?

    Thanks

  2. #2
    SitePoint Zealot w1nk5's Avatar
    Join Date
    Aug 2009
    Location
    Ontario, Canada
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i got it! I changed it to use shorthand php and it worked.

    Code:
    <?php $pagenum = $wp_query->query_vars; ?>
    <?php $pagenum = $pagenum['paged']; ?>
    		
    <?php if($pagenum == 0) { ?>
       <div id="bio">
          <img src="<?php bloginfo("template_directory"); ?>/img/gerry.jpg" />
       </div>
    <?php } ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •