Fisrt we should clarify are you talking about posts or Pages?
Don’t bump after an hour or two!
Patience is highly appreciated by the volunteer helpers.
Probably nobody came around that has an answer for your question. For sure, I don’t.
Perhaps you could elaborate on the details? Sounds like you are trying to do some custom work here, and using the post ID might be the way to go. It’s hard to say without knowing the context though.
Sorry about bumping to quick.
To elaborate, here is the code Im using to output the posts.
<? $pageid="post-<?php the_ID(); ?>"; ?>
<ul>
<?php $lastposts = get_posts('numberposts=20'); foreach($lastposts as $post) : setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
All I basically want is to have a css class applied to the list. Ive tried the following below.
<? $pageid="post-<?php the_ID(); ?>"; ?>
<ul>
<?php $lastposts = get_posts('numberposts=20'); foreach($lastposts as $post) :
setup_postdata($post); ?>
<li <? if("post-<?php the_ID(); ?>"==$pageid){echo 'id="current"';}?>><a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
The problem with this is that all outputed links are highlighted.
Please mark this as solved. I have found the solution.
I just added a css property to match the post id
<style type="text/css">
#post-<?php the_ID(); ?> {
background-color: #FFFFFF;
}
</style>
<li class="post-<?php the_ID(); ?>">
<a href="<?php the_permalink(); ?>" id="post-<?php the_ID(); ?>"><?php the_title(); ?></a>
</li>
You should mark it solved π
(up where the title is)
sory, i dont get this -if i try this solution, all links are highlighted?
I used the code of machinetype (thanks), but instead of highlight like this:
post 1
post 2
“post 3 highlight”
post 4
Put some other title down the other post title, like this:
post 1
post 2
post 3
post 4
“post 3 highlight”
Is that what it spouse to do, or I put it wrong?