Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 33
  1. #1
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    Wordpress guru advice needed lol

    So here we go...

    I have a div on my page 380px X 160px, its basically going to display small parts of posts located on the main news page which has catagories etc...

    My question is how can i set this up so no matter how many posts my client puts up they wont exceed four posts in this box and the box will remain fixed at its size.

    any help please
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    A couple of questions ....

    1) Display 4 latest posts from 1 category, or 1 latest post from 4 categories?

    2) The title and just a portion of the content, or just the title? How much of the post to show,
    and you realize there would be a problem if the latest post had a photo in it?


  4. #3
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    display the last four posts in total doesnt matter what catagory.

    title and a portion of the content, i realise there will be a problem if an image is uploaded, but cant you make it into text for the news feed?

    cheers
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  5. #4
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    I would do it like this ...

    First, get it to display the latest 4 posts on your page. Don't worry about them fitting in the <div> at this point, just make them display on a page. I'm not sure how you're going to insert this ... not knowing whether you have a custom main page, or whatever you're doing. In any case, you would be modifying a file in your theme directory (edit your templates). Or child theme if that's the way you're rolling.

    Example code to try:
    PHP Code:
    <ul>
    <?php
    $args 
    = array( 'numberposts' => '4' );
    $recent_posts wp_get_recent_posts$args );
    foreach( 
    $recent_posts as $recent ){
    echo 
    '<li><a href="' get_permalink($recent["ID"]) . '" title="Look '.esc_attr($recent["post_title"]).'" >' .  $recent["post_title"].'</a> </li> ';
    }
    ?>
    </ul>
    Here is the source of the WordPress CODEX:
    http://codex.wordpress.org/Function_...t_recent_posts

    Once you get them to display, you can then deal with the layout, CSS, and your <div>.


  6. #5
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    i already have them displayed, i need to figure out how to only have 4 posts displaying as a max and with a limit to the amount of text it displays..

    thanks again
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Can you get it to display 4 posts by using some of the example I showed?
    Let's try to do that first.


  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Better yet, can you post the code you're using now?


  9. #8
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    ive got this...

    <!-- Start the Loop. -->
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <!-- Test if the current post is in category 3. -->
    <!-- If it is, the div box is given the CSS class "post-cat-three". -->
    <!-- Otherwise, the div box is given the CSS class "post". -->
    <?php if ( in_category('3') ) { ?>
    <div class="post-cat-three">
    <?php } else { ?>
    <div class="post">
    <?php } ?>

    <!-- Display the Title as a link to the Post's permalink. -->
    <div class="b_title">

    <a href="<?php the_permalink() ?>" rel="bookmark" class="b_title" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>

    <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
    <div class="b_date"><?php the_time('F jS, Y') ?></div>

    <!-- Display the Post's Content in a div box. -->
    <div class="b_text1">
    <?php the_content(); ?>
    </div>

    </div> <!-- closes the first div box -->

    <!-- Stop The Loop (but note the "else:" - see next line). -->
    <?php endwhile; else: ?>

    <!-- The very first "if" tested to see if there were any Posts to -->
    <!-- display. This "else" part tells what do if there weren't any. -->
    <p>Sorry, no posts matched your criteria.</p>

    <!-- REALLY stop The Loop. -->
    <?php endif; ?>
    and it is working... but im not sure where to put the part that limits the ammount of posts...
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  10. #9
    Senior Member kirman's Avatar
    Join Date
    May 2003
    Location
    UK England
    Posts
    765
    Member #
    1499
    Liked
    2 times
    just noticed i dont need all that code lol
    Dream like you'll live forever. Live like you're gonna die 2morrow!

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    Change this:
    <?php the_content(); ?>

    To this:
    <?php the_excerpt(); ?>
    That should show the "shortened" version of the content.

    I'll see what to do about the quantity.



Page 1 of 4 1 2 3 ... LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 04:58 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com