What I need is to display posts with a specific tag on a page. I just can't get it to work. Plus, I'm also working on the thesis platform so its even more confusing.
I need some sort of php code for the tag ('organized-crime')to display on page 6698.
Something along the lines of
function organized_crime_page() {
if (is_page('6698')) {
}
}
add_action('thesis_hook_before_content', 'organized_crime_page');
and have it display the tag ('organized-crime') or the tag_id (133).
Do I have to insert all of the php code for title, entry, tags? I keep thinking that there must be a simpler way so that I can just grab the tag and have it displayed without adjusting the stylesheet. I have over 100 pages where this code will need to be placed on, so simple fixes are needed.
Arnav Joy answers:
try this
function organized_crime_page() {
if (is_page('6698')) {
global $post;
$postsByTag = get_posts('tag=organized-crime&numberposts=-1');
// now for each post do what you need
foreach($postsByTag as $post) {
setup_postdata($post);
echo '<a href="'. get_permalink().'">'. get_the_title().'</a><br />'.get_the_excerpt();
}
}
}
add_action('thesis_hook_before_content', 'organized_crime_page');
vitaminman comments:
No, that didn't work.
Man, I hate thesis. I shouldn't have switched over.
The code you provided grabs some posts, but it isn't formatted at all to the stylesheet. (see attached image)
Thesis uses this weird css style sheet. This is an example of what they do:
function category() {
thesis_archive_intro();
echo "<div class=\"post_box top\">\n";
echo "\t<div class=\"format_text\">\n";
echo "\t\t<ul>\n";
while (have_posts()) {
the_post();
echo "\t\t\t<li><a href=\"" . get_permalink() . "\">" . get_the_title() . "</a></li>\n";
}
echo "\t\t</ul>\n";
echo "\t</div>\n";
echo "</div>\n";
}
The line that you gave me of if
$postsByTag = get_posts('tag=organized-crime&numberposts=-1');
is helpful, because I didn't know how to write that. But I still have no idea how to style this.