Forums

[resolved] Adding formatting to a template tag (13 posts)

  1. keress
    Member
    Posted 3 years ago #

    I've found this code to bring in the titles and links to the latest three blogs on our site:

    <div class="latest-blogs">
    <?php wp_get_archives('type=postbypost&limit=3&format=latest-blog'); ?>
    </div>

    I need to know how to add formatting so that each title is on its own line, separated either by a <p> or a

  2. (preferably a
  3. )

    Can anybody tip me off on how to do this?

  • Otto
    Tech Ninja
    Posted 3 years ago #

    Instead of trying to add HTML, consider using CSS styling instead.

    Give a link to your blog, so we can see the HTML being generated.

  • vachi
    Member
    Posted 3 years ago #

    also, that would be like, latest-blogs a , or latest-blogs h4, h2, h1

    and so on, you would create these styles in the theme style.css file and see what happens
    and if you are on mac try using cssEdit

  • keress
    Member
    Posted 3 years ago #

    Thanks for the speedy replies. This is the page. It's the green section under the large photo "Latest from the blog." If you'll check the source, I'm not able to add at least a line break between the links.

    http://www.addiva.net/blog/home/

  • vachi
    Member
    Posted 3 years ago #

    how about

    .latest-blogs a {
    	line-height: 22px;
    }
  • keress
    Member
    Posted 3 years ago #

    That would make it look a little better, but what I'm aiming for is something like:

    • It’s not easy being green, especially for ADD women
    • ADHD Hummingbirds?
    • Proud mom of an ADDiva-in-training

    Thanks!

  • vachi
    Member
    Posted 3 years ago #

    well adding this

    list-style-type: disc;

    should do the trick

  • keress
    Member
    Posted 3 years ago #

    But there are no <li>s there. I can't figure out how to get this tag I found in the codex:

    <?php wp_get_archives('type=postbypost&limit=3&format=latest-blogs'); ?>

    to output a list instead of a big run on sentence like it is. There's nothing there to create a list with any kind of line break. I'd settle for a simple <br /> at this point.

  • keress
    Member
    Posted 3 years ago #

    Does wordpress have a tag that will generate an ~ordered~ list of blog titles/links rather than this unordered one?

  • vachi
    Member
    Posted 3 years ago #

    i don't think so, lists and so on are generated because they are in a tag such as

  • keress
    Member
    Posted 3 years ago #

    Found it! It's

    <ul>
     <?php
     global $post;
     $myposts = get_posts('numberposts=4&offset=1');
     foreach($myposts as $post) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     </ul>
  • vachi
    Member
    Posted 3 years ago #

    see its in a

  • tag thats what putting it in a list, glad you have found it, very useful actually :)
  • Otto
    Tech Ninja
    Posted 3 years ago #

    <?php wp_get_archives('type=postbypost&limit=3&format=latest-blogs'); ?>

    What is that "format=latest-blog" bit for? If you remove that, you'll get it in a list format.

    <ul class="latest-blogs">
    <?php wp_get_archives('type=postbypost&limit=3'); ?>
    </ul>
  • Topic Closed

    This topic has been closed to new replies.

    About this Topic

    Tags