Hi,
What need to be changed on this code so it takes from just one category not the whole site?
Thanks in advanceCode:<?php wp_get_archives('type=postbypost&limit=10'); ?>
Sami
Printable View
Hi,
What need to be changed on this code so it takes from just one category not the whole site?
Thanks in advanceCode:<?php wp_get_archives('type=postbypost&limit=10'); ?>
Sami
Can try this
Just replace the #1 with the category # you want to use.PHP Code:<?php wp_get_archives('cat=1'); ?>
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 likeso this would be category number 71 :)Quote:
cat_ID=71
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'); ?>
Hi,
I Just tried that code it don't work. :(
Instead of showing what is in that category I get the MO.
Sami
Here is a working piece of code that will show the latest post in a category of your choice
ChangePHP 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; ?>
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.Quote:
XXXXXXXXX
Hi,
This code works :) Thanks. On my site.
Now I have one more question.
Is there a way that this line can be changed.
So that it pulls NOT the whole title just the first two words of the title?Code:<?php the_title(); ?>
http://www.netbuilders.org/attachmen...1&d=1270312065
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
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
then you can change in your template where you put the other codePHP 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;
}
toPHP Code:<?php the_title(); ?>
This linePHP Code:<?php echo ShortenText(get_the_title()); ?>
is what would be edited to fit your length needsPHP Code:$chars_limit = 20;
Hi.
Yes, shorten the title to the first two words. :)
This Clint Eastwood Biography, Filmography, Pictures
Would become this Clint Eastwood...
Sami