danpacey
Forum Replies Created
-
Forum: Plugins
In reply to: How to show links to other posts from same Category?I’ve been battling with this for a while, and here’s what i’ve come up with.
<?php global $post; $categories = get_the_category(); $thiscat = $categories[0]->cat_ID; ?> <?php query_posts('showposts=5&orderby=rand&cat=' . $thiscat); ?> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> YOUR CONTENT HERE <?php endwhile; else : ?> Error returning query. <?php endif; ?> <?php wp_reset_query(); ?>I’m not sure if that is horrendous or pretty smart, but either way it seems to work, returning all posts that are in the same category as the post being viewed – but only the FIRST category ID, ie:
Post is in categories A, B & C. The query shows all posts that are also in A, since A was the first cat listed.
Hope this helps.
Forum: Plugins
In reply to: automatic insertion of “http://” to comment_author_urlPerhaps instead of the above I can use whatever code generates the output in the image below, on the Edit Comments admin page:
This strips http:// and www. from values stored in comment_author_url.. but I just can’t find the code for this in the core files.
Anyone got any ideas?
Thanks again.
Forum: Fixing WordPress
In reply to: Search using Select Option drop box populated by Custom Fieldok, an update. I’m getting the right amout of results from this code, but not the actual values.
<?php $querystr = " SELECT DISTINCT wp_postmeta.* FROM wp_postmeta WHERE $wpdb->postmeta.meta_key = 'area' "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <option value="<?php echo get_post_meta($post->ID, 'area', true); ?>"><?php echo get_post_meta($post->ID, 'area', true); ?></option> <?php endforeach; ?> <?php endif ?>1I have 9 “area” values in the wp_postmeta table at present, and i’m getting a list with 9 <option> tags.. but there is nothing in-between the option tags..
putting this here in case anyone has any idea what i’m doing wrong. Many thanks again.
Forum: Fixing WordPress
In reply to: Search using Select Option drop box populated by Custom Fieldnot getting anywhere fast with this, can anyone offer any advice please? thanks guys. Seems like a useful function, if it can be done!
Forum: Fixing WordPress
In reply to: Search using Select Option drop box populated by Custom Fieldok at the moment i am trying to run this code, but it’s not generating any results.
<?php $querystr = " SELECT DISTINCT wp_posts.* FROM wp_posts LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id) LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id) LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) WHERE $wpdb->term_taxonomy.term_id = 3,4,5,6,7,8,9 AND $wpdb->term_taxonomy.taxonomy = 'category' AND $wpdb->posts.post_status = 'publish' AND $wpdb->postmeta.meta_key = 'area' ORDER BY $wpdb->postmeta.meta_value ASC "; $pageposts = $wpdb->get_results($querystr, OBJECT); ?> <?php if ($pageposts): ?> <?php foreach ($pageposts as $post): ?> <?php setup_postdata($post); ?> <option value="<?php echo get_post_meta($post->ID, 'area', true); ?>"><?php echo get_post_meta($post->ID, 'area', true); ?></option> <?php endforeach; ?> <?php endif ?>any ideas?
will keep trying in the meantime!
Forum: Fixing WordPress
In reply to: Changing the Category of a PageI’ll have a look at that, thanks for your help!
The pages i have this problem with are template files, but they aren’t pulling in anything with query_posts. I’m quite baffled by this one!
thanks again!
Forum: Your WordPress
In reply to: Examples of WP that don’t look like blogs?<!– double post –> π
Forum: Your WordPress
In reply to: Examples of WP that don’t look like blogs?interseting topic – i think you can do a lot with wordpress, especially if you really make use of query_posts. I’m working on two sites at the moment, this one (my portfolio site) is nearly complete (will be changing/adding a few things), and i think fits the bill for being “non-bloglike”!
i’m making use of custom fields and comments for my own ends.
Forum: Fixing WordPress
In reply to: Changing the Category of a PageAlso: if I change the submenu code to
‘if(in_category(‘2′)’
for example, the correct class is called. Therefore.. the Page MUST be in Cat 3. It’s the only explanation.
Forum: Fixing WordPress
In reply to: Changing the Category of a PageI am using PHP to define CSS classes, based on
ifstatements:main header menu code
<a href="?page_id=4" <?php if(is_page('4')){ echo 'class="menu3_on"'; } else { echo 'class="menu3"'; } ?>>Group</a> <a href="?page_id=5" <?php if(is_page('5')){ echo 'class="menu4_on"'; } else { echo 'class="menu4"'; } ?>>Contact</a>problematic submenu code:
<li <?php if(in_category('3') ){ echo 'class="sub1_on"';} else {echo 'class="sub1"';} ?>> <a href="?cat=3" (etc)I honestly cannot see anything in there that would cause it. I thought all pages were assigned to whatever the default Category is on creation? All of which leads me to think these Pages are assigned to Cat 3.
thanks for your help this far!