paulanthony
Forum Replies Created
-
Forum: Networking WordPress
In reply to: Multisite register_nav_menuRock and roll gents.
Thanks to the both of you ??
Forum: Hacks
In reply to: wp_dropdown_cat and a html formSomething like this?
echo '<select id="mb_category" name="mb_category"> <option value=""> --- Select a Category --- </option>'; // Get the categories from the DB global $wpdb; $results = $wpdb->get_results( "SELECT id, name FROM category", ARRAY_A ); foreach( $results as $result ) { echo ' <option value="' . $result['id'] . '" >' . $result['name'] . '</option>'; } echo '</select>';
Forum: Hacks
In reply to: How do I modify wordpress's defualt searchYou’ll need to look into a specific hook for this, then join your tables with the WP standard tables (probably a left join to bring back wp stuff and your own).
Initially thought that post_where was the hook you need, but it’s been depreciated. Will look into the current one and come back here.
Forum: Themes and Templates
In reply to: Get Sub Pages but custom HTMLAlright folks I found the answer. You have to override the Walker class. you can find this in classes.php
class Walker_Webdistortion extends Walker { var $tree_type = 'page'; var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul class='subpage'>\n"; } function end_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent</ul>\n"; } function start_el(&$output, $page, $depth, $current_page, $args) { if ( $depth ) $indent = str_repeat("\t", $depth); else $indent = ''; extract($args, EXTR_SKIP); $css_class = 'page_item page-item-'.$page->ID; if ( !empty($current_page) ) { $_current_page = get_page( $current_page ); if ( in_array($page->ID, (array) $_current_page->ancestors) ) $css_class .= ' current_page_ancestor'; if ( $page->ID == $current_page ) $css_class .= ' current_page_item'; elseif ( $_current_page && $page->ID == $_current_page->post_parent ) $css_class .= ' current_page_parent'; } //get custom field toplevel=1 then dont link $custom_fields = get_post_custom($page->ID); $my_custom_field = $custom_fields['toplevel']; if($my_custom_field[0]==1){ $output .= '<div>'. attribute_escape(apply_filters('the_title', $page->post_title)) .'</div>'; }else{ $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . attribute_escape(apply_filters('the_title', $page->post_title)) . '">' . apply_filters('the_title', $page->post_title) . '</a>'; } if ( !empty($show_date) ) { if ( 'modified' == $show_date ) $time = $page->post_modified; else $time = $page->post_date; $output .= " " . mysql2date($date_format, $time); } } function end_el(&$output, $page, $depth) { $output .= "</li>\n"; } }
Then create a copy of the wp_list_pages function. And wack that into your page.
<?php function my_wp_list_pages($args = '') { $defaults = array( 'depth' => 0, 'show_date' => '', 'date_format' => get_option('date_format'), 'child_of' => 0, 'exclude' => '', 'title_li' => '', 'echo' => 1, 'authors' => '', 'sort_column' => 'menu_order, post_title', 'link_before' => '', 'link_after' => '' ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); $output = ''; $current_page = 0; // sanitize, mostly to keep spaces out $r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']); // Allow plugins to filter an array of excluded pages $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude']))); // Query pages. $r['hierarchical'] = 1; $pages = get_pages($r); if ( !empty($pages) ) { if ( $r['title_li'] ) $output .= '<li class="pagenav">' . $r['title_li'] . '<ul>'; global $wp_query; if ( is_page() || $wp_query->is_posts_page ) $current_page = $wp_query->get_queried_object_id(); $output .= walk_page_webdistortion($pages, $r['depth'], $current_page, $r); if ( $r['title_li'] ) $output .= '</ul></li>'; } //$output = apply_filters('wp_list_pages', $output); if ( $r['echo'] ) echo $output; else return $output; } echo(my_wp_list_pages()); ?>
Notice $output .= walk_page_webdistortion
Finally tie up your class. In post_template.
function walk_page_webdistortion(){ $walker = new Walker_Webdistortion; $args = func_get_args(); return call_user_func_array(array(&$walker, 'walk'), $args); }
You’ll also need to create custom fields for each page which is a pseduopage. toplevel=1 is the variable I checked for in the custom Walker class.
disclaimer. I’m not a PHP coder, so this stuff was relatively alien to me. There is probably a much tidier cleaner way of doing this, but please WP developers lets get the html out of the codebase, or if it must go into it, get it configurable for each function.
Forum: Themes and Templates
In reply to: Get Sub Pages but custom HTMLForum: Themes and Templates
In reply to: Get Sub Pages but custom HTMLhttps://www.ads-software.com/support/topic/220935?replies=1
Same problem as here.
Forum: Themes and Templates
In reply to: Get Sub Pages but custom HTMLwp_list_pages relies heavily on get_pages(), or seems to. I’ll need to modify / copy paste it as well, which seems like an ugly solution to a relatively small problem.
Forum: Themes and Templates
In reply to: Get Sub Pages but custom HTML<div> <?php $children = wp_list_pages("title_li=&echo=0"); if ($children) { ?> <ul> <?php echo $children; ?> </ul> <?php } ?> </div>
Or in other words – the above code, without the parents being linked.