Steven
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Counting posts within categoriesNope, this doesn’t work either….
$table_prefix = $wpdb->prefix; $querystr = " SELECT (*) FROM {$table_prefix}posts, {$table_prefix}term_relationships, {$table_prefix}term_taxonomy WHERE {$table_prefix}posts.ID = {$table_prefix}term_relationships.object_id AND {$table_prefix}term_relationships.term_taxonomy_id = {$table_prefix}term_taxonomy.term_taxonomy_id AND {$table_prefix}term_taxonomy.taxonomy = 'category' AND {$table_prefix}term_taxonomy.term_id = 21 AND post_status = 'publish' AND post_type != 'page' ";
Forum: Fixing WordPress
In reply to: Counting posts within categoriesI think I’m on a wild track with a LEFT JOIN right?
I should maybe use sub selection. Something like$querystr = " SELECT COUNT(*) FROM $wpdb->posts, $wpdb->term_taxonomy WHERE posts.post_type = 'post' AND posts.post_status = 'publish' AND ID = term_id AND term_id = 21; "; $result = $wpdb->get_var($querystr);
After reading about the WordPress Taxanomy, I’m a bit uncertain if I should use wp_term_relationships or wp_term_taxonomy.
All I need is to count the number of published posts in a category. Shouldn’t bee that hard….
Forum: Fixing WordPress
In reply to: How to remove ‘Recent Posts’ from sidebarThe empty bar is a result of CSS classes.
edit the styles.css if you want remove the bottom border.
Forum: Fixing WordPress
In reply to: Counting posts within categoriesAny suggestions anyone?
Any help is appreciated ??Forum: Fixing WordPress
In reply to: Post count by categoryI’m continuing this post here.
Forum: Fixing WordPress
In reply to: Post count by categoryOk, I’m almost there.
This code ouputs the number of posts in the category.function get_post_count($categories) { global $wpdb; $post_count = 0; foreach($categories as $cat) : $querystr = " SELECT count FROM $wpdb->term_taxonomy WHERE term_id = $cat"; $result = $wpdb->get_var($querystr); $post_count += $result; endforeach; return $post_count; }
Now I have to figure out how to subtract the number of posts which is not published.
I think I will needing to use a LEFT JOIN (or RIGHT JOIN).
But I’m not good using JOIN.Forum: Fixing WordPress
In reply to: Post count by category“wp_list_categories, displays a list of Categories as links”
Any suggestions on how I can avoid listing categories?
And just get the post count?Forum: Fixing WordPress
In reply to: Post count by categoryHi Velvet.
I’m not counting the categories, but the number of posts within one or more categories.In the page template I have a meta_tag for which categories I would like display posts. I retrieve all posts for all categories defined in the meta_tag.
Now I need to display how many posts that is.
Forum: Fixing WordPress
In reply to: Rearranging post ordersIn the query_posts() have you tried using ‘order=ASC’ or ‘order=DES’?
I use the following code:
query_posts(“$cat&paged=$page&orderby=title&order=ASC”);($cat is a concatinated string and $page is for pagiantion purpose)
Forum: Fixing WordPress
In reply to: Paged CommentsSomething like this?
https://www.keyvan.net/code/paged-comments/Forum: Fixing WordPress
In reply to: how to use the_title() in ALT tagsDidn’t quite understand you answer hotkee.
I am using query_posts()
query_posts(‘showposts=3&cat=15’);Well, I’ve created a workaround. I’ve added a custom fild fot image title and will use this for ALT text.
Forum: Fixing WordPress
In reply to: how to use the_title() in ALT tags<div id="leftcol"> <?php // "Featured articles" (Nyheter) module begins query_posts('showposts=3&cat=15'); ?> <h3> Nyheter </h3> <?php while (have_posts()) : the_post(); ?> <div class="feature"> <?php $basePath = get_option('upload_path') . '/'; $permaLink = get_permalink(); // this grabs the image filename ffrom image gallery $values = get_post_custom_values("featuredarticleimage"); // this checks to see if an image file exists if(empty($values[0])) { //Grab url to external image $values = get_post_custom_values("externalthumb"); $basePath = ''; } // If and image has been related, it will be displayed if(!empty($values[0])) { echo '<a href="' . $permaLink . '">'; echo '<img src="' . $basePath[0] . $values[0] . '" alt="artikkelbilde" />'; echo '</a>'; } ?> <a href="<?php the_permalink() ?>" rel="bookmark" class="title"> <?php the_title(); ?> </a> <p> <?php the_content_rss('Les mer','', '', 20); ?> <a href="<?php the_permalink() ?>">Les mer</a>. </p> </div> <?php endwhile; ?> </div> <!--END LEFTCOL-->
See the line echo ‘<img src=”‘ . $basePath[0] . $values[0] . ‘” alt=”artikkelbilde” />’; ?
I will replace ‘artikkelbilde’ with the_title() and the new code looks like this:
echo ‘<img src=”‘ . $basePath[0] . $values[0] . ‘” alt=”‘ . the_title() . ‘” />’;Notice the small linked text in front of the headline. This is the ALT text. If you look at the source code, you will see alt=””.
Forum: Fixing WordPress
In reply to: how to use the_title() in ALT tagsThat was quick ??
I think it’s within a custom loop?<?php while (have_posts()) : the_post(); ?>
(... , my code here)
<?php endwhile; ?>