Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: WP code change help Please.

  1. #1
    Sami4u's Avatar
    Sami4u is offline Butterflies Forever
    Join Date
    Sep 2009
    Location
    USA
    Posts
    1,421
    Thanks
    697
    Thanked 293 Times in 221 Posts

    WP code change help Please.

    Hi,

    What need to be changed on this code so it takes from just one category not the whole site?

    Code:
    <?php wp_get_archives('type=postbypost&limit=10'); ?>
    Thanks in advance

    Sami
    Current Celebrity Gossip Movies & More TV Site
    Find out how I'm able to get up to 420 backlinks for month, by spending 30 seconds per day...all for FREE! - Click Here

  2. #2
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    Can try this

    PHP Code:
    <?php wp_get_archives('cat=1'); ?>
    Just replace the #1 with the category # you want to use.

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  3. Thanked by:

    Aziz (3 April, 2010), bogart (3 April, 2010), Will.Spencer (5 April, 2010)

  4. #3
    Sami4u's Avatar
    Sami4u is offline Butterflies Forever
    Join Date
    Sep 2009
    Location
    USA
    Posts
    1,421
    Thanks
    697
    Thanked 293 Times in 221 Posts
    Quote Originally Posted by Mr.Bill View Post
    Can try this

    PHP Code:
    <?php wp_get_archives('cat=1'); ?>
    Just replace the #1 with the category # you want to use.
    Hi,

    What do you mean category #? Where do I find that?

    Sami
    Current Celebrity Gossip Movies & More TV Site
    Find out how I'm able to get up to 420 backlinks for month, by spending 30 seconds per day...all for FREE! - Click Here

  5. #4
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    if you go into your admin area and open up categories then hover your mouse over the category you want you should see the category number at the end of the url will be something like
    cat_ID=71
    so this would be category number 71

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  6. Thanked by:

    Aziz (3 April, 2010), Will.Spencer (5 April, 2010)

  7. #5
    Aziz's Avatar
    Aziz is offline no investment, no glory
    Join Date
    May 2009
    Location
    IL
    Posts
    736
    Thanks
    588
    Thanked 243 Times in 168 Posts
    so for example if the desired category has the ID 23 the final code would be something like

    PHP Code:
    <?php wp_get_archives('cat=23'); ?>

  8. Thanked by:

    Will.Spencer (5 April, 2010)

  9. #6
    Sami4u's Avatar
    Sami4u is offline Butterflies Forever
    Join Date
    Sep 2009
    Location
    USA
    Posts
    1,421
    Thanks
    697
    Thanked 293 Times in 221 Posts
    Hi,

    I Just tried that code it don't work.

    Instead of showing what is in that category I get the MO.

    Sami
    Current Celebrity Gossip Movies & More TV Site
    Find out how I'm able to get up to 420 backlinks for month, by spending 30 seconds per day...all for FREE! - Click Here

  10. #7
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    Here is a working piece of code that will show the latest post in a category of your choice


    PHP Code:
    <?php query_posts('category_name=XXXXXXXXX&showposts=1'); ?>
    <?php 
    while (have_posts()) : the_post(); ?>
            <li><a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a>  </li>
            <?php endwhile; ?>
    Change
    XXXXXXXXX
    to the exact name of your category and if you want to show more then just one post change the 1 to a different value.
    Last edited by Mr.Bill; 3 April, 2010 at 16:11 PM.

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  11. Thanked by:

    Sami4u (3 April, 2010), Will.Spencer (5 April, 2010)

  12. #8
    Sami4u's Avatar
    Sami4u is offline Butterflies Forever
    Join Date
    Sep 2009
    Location
    USA
    Posts
    1,421
    Thanks
    697
    Thanked 293 Times in 221 Posts
    Quote Originally Posted by Mr.Bill View Post
    Here is a working piece of code that will show the latest post in a category of your choice


    PHP Code:
    <?php query_posts('category_name=XXXXXXXXX&showposts=1'); ?>
    <?php 
    while (have_posts()) : the_post(); ?>
            <li><a href="<?php the_permalink(); ?>">
              <?php the_title(); ?>
              </a>  </li>
            <?php endwhile; ?>
    Change to the exact name of your category and if you want to show more then just one post change the 1 to a different value.
    Hi,

    This code works Thanks. On my site.

    Now I have one more question.

    Is there a way that this line can be changed.

    Code:
    <?php the_title(); ?>
    So that it pulls NOT the whole title just the first two words of the title?



    All my bio's are titled the same way just the name is changed.

    So it would read.

    Current Bio's

    Clint Eastwood
    Lady Gaga
    LL Cool J
    George Clooney
    Chris O’Donnell

    Sami
    Current Celebrity Gossip Movies & More TV Site
    Find out how I'm able to get up to 420 backlinks for month, by spending 30 seconds per day...all for FREE! - Click Here

  13. #9
    Mr.Bill's Avatar
    Mr.Bill is offline One is glad to be of service
    Join Date
    Dec 2008
    Location
    Redmond, Oregon
    Posts
    828
    Blog Entries
    1
    Thanks
    72
    Thanked 350 Times in 182 Posts
    You want to truncate the title so it would be like this

    WP code change...
    instead of
    WP code change help Please.

    or do you want it to show something else?



    If you just want to shorted the title then you can do this

    in your admin area go to you edit template are and look for functions.php and add this right after <?php

    PHP Code:
    function ShortenText($text)

    {

    // Change to the number of characters you want to display

    $chars_limit 20;

    $chars_text strlen($text);

    $text $text." ";

    $text substr($text,0,$chars_limit);

    $text substr($text,0,strrpos($text,' '));

    // If the text has more characters that your limit,
    //add ... so the user knows the text is actually longer

    if ($chars_text $chars_limit)

    {

    $text $text."";

    }

    return 
    $text;


    then you can change in your template where you put the other code

    PHP Code:
    <?php the_title(); ?>
    to

    PHP Code:
    <?php echo ShortenText(get_the_title()); ?>
    This line
    PHP Code:
    $chars_limit 20
    is what would be edited to fit your length needs

    Reverse IP Check ಠ_ಠ Proxy Sites
    <?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>

  14. Thanked by:

    Will.Spencer (5 April, 2010)

  15. #10
    Sami4u's Avatar
    Sami4u is offline Butterflies Forever
    Join Date
    Sep 2009
    Location
    USA
    Posts
    1,421
    Thanks
    697
    Thanked 293 Times in 221 Posts
    Hi.

    Yes, shorten the title to the first two words.

    This Clint Eastwood Biography, Filmography, Pictures

    Would become this Clint Eastwood...

    Sami
    Current Celebrity Gossip Movies & More TV Site
    Find out how I'm able to get up to 420 backlinks for month, by spending 30 seconds per day...all for FREE! - Click Here

Page 1 of 2 12 LastLast

Similar Threads

  1. change about the world?
    By theezy in forum General Chat
    Replies: 7
    Last Post: 17 May, 2010, 21:49 PM
  2. [WTH] Someone to Change Text on a .PSD
    By Kovich in forum Marketplace
    Replies: 1
    Last Post: 22 April, 2010, 08:20 AM
  3. A question about change in url
    By mega in forum Promoting
    Replies: 3
    Last Post: 21 July, 2009, 07:06 AM
  4. One Change You Would Like To See On WMP?
    By Farrhad A in forum General Chat
    Replies: 13
    Last Post: 3 June, 2009, 08:34 AM

Tags for this Thread

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
  •