Martin Black
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Function using custom SQL to return array of specific category IDSolved as follows:
function get_positional_categories() { global $wpdb; $poscats = $wpdb->get_results(" SELECT name,term_id FROM <code>wp_terms</code> WHERE name LIKE '\_%'; "); $count = 0; foreach ($poscats as $pcat) { $poscats[$count] = $pcat->term_id; $count++; } return $poscats; }
Forum: Fixing WordPress
In reply to: WordPress Page List (only a href links, no styling).Managed to achieve this as follows:
<?php $pages = get_pages('sort_column=menu_order&title_li='); $content .= "<span>"; foreach ($pages as $pagg) { $content .= '<a href="'.get_page_link( $pagg->ID ).'">'.$pagg->post_title.'</a>'; } $content .= "</span>"; echo $content; ?>
Forum: Fixing WordPress
In reply to: Automatically create categoriesSolved using Category Importer
Forum: Fixing WordPress
In reply to: Random Posts with Featured ImageExcellent. Thanks!
Forum: Fixing WordPress
In reply to: Random Posts with Featured ImageI believe that this requires a join between
wp_posts
table and thewp_postmeta
table wherein lies_wp_attached_file
though I’m not sure if this correct. Or how to do it. Any help would be appreciated.Thanks
Forum: Fixing WordPress
In reply to: Author Posts Page – exclude postsI have solved this by simply using the
query_posts
to exclude categories. Myauthor.php
now has this line just before the loop starts:<?php query_posts($query_string . '&cat=-69,-68'); ?> <?php while (have_posts()) : the_post(); ?>
Forum: Fixing WordPress
In reply to: WordPress variable (the_category) between template filesAny guidance on turning it into a function? Would I use a filter on the function
get_the_category()
?Forum: Fixing WordPress
In reply to: Display tags from a specific category and sort themJust in case anyone was wondering, I managed to fix this issue with this amended SQL in my functions.php
function get_category_tags($args) { global $wpdb; $tags = $wpdb->get_results (" SELECT DISTINCT terms2.term_id as tag_id, terms2.name as tag_name, null as tag_link, t2.count as post_total FROM wp_posts as p1 LEFT JOIN wp_term_relationships as r1 ON p1.ID = r1.object_ID LEFT JOIN wp_term_taxonomy as t1 ON r1.term_taxonomy_id = t1.term_taxonomy_id LEFT JOIN wp_terms as terms1 ON t1.term_id = terms1.term_id, wp_posts as p2 LEFT JOIN wp_term_relationships as r2 ON p2.ID = r2.object_ID LEFT JOIN wp_term_taxonomy as t2 ON r2.term_taxonomy_id = t2.term_taxonomy_id LEFT JOIN wp_terms as terms2 ON t2.term_id = terms2.term_id WHERE t1.taxonomy = 'category' AND p1.post_status = 'publish' AND terms1.term_id IN (".$args['categories'].") AND t2.taxonomy = 'post_tag' AND p2.post_status = 'publish' AND p1.ID = p2.ID ORDER BY post_total DESC "); $count = 0; foreach ($tags as $tag) { $tags[$count]->tag_link = get_tag_link($tag->tag_id); $count++; } return $tags; }
Forum: Fixing WordPress
In reply to: Author and Timstamp on PagesThats done it. thanks ??
Forum: Fixing WordPress
In reply to: Author and Timstamp on PagesHmm, adding those tags into the Loop caused an error in Syntax on Line 27.
I added this:
<p align="right">Last edited by <?php the_modified_author(); ?> on <?php the_modified_time('Fj, Y'); ?>at <?php the modified_time('g:i a'); ?> </p>