• On a foreign page(to WP) I’m importing the titles to a block. As usual, the titles contain links back to their article page. In some cases, the title are so long, it is not attractive to have the whole thing appear on a title list.

    I found this code:

    <?php $thetitle = $post->post_title; echo substr($thetitle, 0, 26); ?>

    but it didn’t work. Was there a particular place I was suppose to insert or some words replaced?

    Here is the code I have now that supplies the link:

    <table cellpadding="2">
              <tr>
                <td>ENB S&D News</td>
              </tr>
              <?php do { ?>
              <tr>
                <td><a href="<?php echo $row_try123['guid']; ?>"><?php echo chop($row_try123['post_title']); ?></a></td>
              </tr>
              <?php } while ($row_try123 = mysql_fetch_assoc($try123)); ?>
            </table>

    please let me know what works, and how to make it work.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • In your code:

    <?php echo substr(chop($row_try123['post_title']), 0, 26); ?>

    Thread Starter howhite

    (@howhite)

    Thank for the information. I changed my code to look like this:

    <table cellspacing="2">
            <tr>
              <td>post_title</td>
            </tr>
            <?php do { ?>
              <tr>
                <td><ul>
                  <li><a href="<?php echo $row_Recordset1['guid']; ?>"><?php echo substr(chop($row_try123['post_title']), 0, 26); ?></a></li>
                </ul></td>
              </tr>
              <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
          </table>

    However after do this the title did show up at all. My bullets were there, but no text.

    Any reason you changed the name of your array var?

    <?php echo substr(chop($row_Recordset1['post_title']), 0, 26); ?>

    (And I’m done with PHP 101 for the night…)

    Thread Starter howhite

    (@howhite)

    Thanks Kafkaesqui. ??

    I’m learning as fast as I can. I appreciate your help, that worked.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Shorten amount of title shown???’ is closed to new replies.