WordPress.org

Ready to get started?Download WordPress

Forums

New Posts (18 posts)

  1. pollacap
    Member
    Posted 4 years ago #

    Im trying to figure out through whatever means (php most likely) to figure out if a post is X days old and if it is echo a div.

    I want to make a div appear for new posts to add some information telling the user its new, prob. with an image bg of the div.

    if anyone can help that would be greatly appreciated.

  2. Jonas Grumby
    Member
    Posted 4 years ago #

  3. powerlinebc
    Member
    Posted 4 years ago #

    Hi. I'd like to create one paragraph of each of my new posts on my mainpage, then have the reader continue to another page by adding a "read more" link. This way I can have a number of recent posts on the main page and not have it full with one long post. How do I do this?

  4. Jonas Grumby
    Member
    Posted 4 years ago #

    Change the_content to the_excerpt in index.php of your theme.

  5. powerlinebc
    Member
    Posted 4 years ago #

    OK, I'm kinda new at this. where do I find that?

  6. Jonas Grumby
    Member
    Posted 4 years ago #

    in index.php of your theme

  7. Maiskolben
    Member
    Posted 4 years ago #

    in your ftp client with root access, then the path where do you uploaded your wp. -> root/wp-content/themes/THEMENAME/

  8. powerlinebc
    Member
    Posted 4 years ago #

    Ok, thanks.

  9. Jonas Grumby
    Member
    Posted 4 years ago #

    If you don't have FTP software or don't know how to use it, you can do it with the theme editor in WordPress. Appearance > Editor

  10. Jonas Grumby
    Member
    Posted 4 years ago #

    p.s. Always make a backup in case it gets screwy and has to be put back to the way it was. If you are using the WP theme editor you can copy the code into a .txt file and save it just in case.

  11. pollacap
    Member
    Posted 4 years ago #

    hmm,ok.

    I want my current functions to work as normal, but, for posts that i have posted within the past 4 days i want to echo a div on the frontpage.

    For instance, all posts 3 days old i want it to echo a div saying NEW!

    From the link you gave me it seems to just call the entire post.

  12. Jonas Grumby
    Member
    Posted 4 years ago #

    I think you would have to add a Conditional Tag. You can combine a conditional tag with a query. Unfortunately I can't figure out the exact code for you because it would take me some time.

  13. pollacap
    Member
    Posted 4 years ago #

    i have a script, i just dont know how to call it in the index.php

  14. Jonas Grumby
    Member
    Posted 4 years ago #

    If it's in a separate file in your theme folder (let's say it's named yourfile.php), use

    <?php include(TEMPLATEPATH.'/yourfile.php');?>

  15. pollacap
    Member
    Posted 4 years ago #

    its a php script in functions.php, is there a way to call it from the title or something?

    function childtheme_post_header(){

    can i call that by using

    <?php postheader (); ?>

  16. Jonas Grumby
    Member
    Posted 4 years ago #

    Sorry I don't know. That's not how I would do it.

  17. Maiskolben
    Member
    Posted 4 years ago #

    sure, you can call your function like that, the functions.php is already included by the header.. I tried to figure out what's going on with that newsalertdiv thing you would like to have, but like SS_Minnow said, it takes too much time for gettin this worked.. And I'm not a php crack.

  18. alchymyth
    Forum Moderator
    Posted 4 years ago #

    Im trying to figure out through whatever means (php most likely) to figure out if a post is X days old and if it is echo a div

    without a script, (has to be within the loop):

    <?php
    $age = date('U') - get_the_time('U');
    $daysago=$age/(60*60*24);
    if($daysago<=X) : ?>
    <!-- html output of your extra stuff -->
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags