Not sure what you are trying to do with the target so please provide an example of an a href link with what you want.
But here’s something you can play with:
<?php
$cat_id = get_cat_ID('uncategorized'); //<--your category here
$args=array(
'cat' => $cat_id,
'meta_key'=>'your custom field here',
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo 'List of Posts';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>"rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
}
wp_reset_query(); // Restore global post data stomped by the_post().
?>
Thank you Michael, your code is very close to what I’m after…
I’ll try to expose the whole issue in order to see exactly what I’m after.
I have a plugin that works with forms (don’t know if it’s OK to say which one because it’s a payed one) and with the help of it I want visitors to add links to already published posts. Basically I want visitors to add in a box the title or anchor text and in another box a link. Then, I want their data to be converged into hyperlinks which will be appended to the already published post they’re on.
So in order to do that with my plugin, visitors have to create new posts in a specific category which will be hidden in the front-end. The forms plugin will store in a custom field the post id of the post the visitors submit their info on and with the help of the code you have provided me I want to display the list of submitted links in the initial post.
Hope I managed to explain what I want to do.
However, with the code you’ve provided I managed to display these added links, but on all posts. I think I have to add as a differentiation parameter the post id of the post the visitors were on when they added the info, post id which is stored in the custom field.
The problem is how can I create a loop for the single.php which will call the links by category, and by the value of custom post? This value will be different for every post to which I want visitors to add links.
Do you think this is achievable?
Thank you,
Chris
It might be possible but not sure I know how to do that.
You will want to look at Custom Fields and maybe something will become clearer.
OK Michael, thank you again for your help.
If, by a miracle I get it right, I’ll post the solution here.
By now I haven’t find a solution. Still searching… though I’m not sure if Conditional Tags could be a solution.
Any suggestions on how could I use conditional tags like is_single()? 🙁