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
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'); ?>
Reverse IP Check ಠ_ಠ Proxy Sites
<?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>
Aziz (3 April, 2010), bogart (3 April, 2010), Will.Spencer (5 April, 2010)
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 71cat_ID=71![]()
Reverse IP Check ಠ_ಠ Proxy Sites
<?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>
Aziz (3 April, 2010), Will.Spencer (5 April, 2010)
Will.Spencer (5 April, 2010)
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.XXXXXXXXX
Last edited by Mr.Bill; 3 April, 2010 at 15:11 PM.
Reverse IP Check ಠ_ಠ Proxy Sites
<?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>
Sami4u (3 April, 2010), Will.Spencer (5 April, 2010)
Hi,
This code worksThanks. 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(); ?>
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;
Reverse IP Check ಠ_ಠ Proxy Sites
<?php if ($youask == 'stupid question') { echo ('stupid answer'); } ?>
Will.Spencer (5 April, 2010)
Hi.
Yes, shorten the title to the first two words.
This Clint Eastwood Biography, Filmography, Pictures
Would become this Clint Eastwood...
Sami
Bookmarks