Huw Tyler
Forum Replies Created
-
Forum: Plugins
In reply to: Counting Taxonomy TermsFound it myself, it turns out it’s quite a nice straightforward workaround.
Nice little function if anyone wants it…<?php print @count(get_terms( 'TAXONOMY-NAME' )); ?>
Forum: Themes and Templates
In reply to: Custom post types in custom menusFound this very helpful: https://www.ads-software.com/support/topic/custom-post-type-in-wordpress-30-menu?replies=8
Fixed!
Forum: Plugins
In reply to: Thumbnail as menu itemGOT IT!
Thanks so much for all your help… a true expert.
The effect is exactly what I wanted and I’ve spend literally days trying to figure this out. Tempted to export that section of code as a plugin. Could be really useful. I’ve not seen it done before.Forum: Plugins
In reply to: Thumbnail as menu itemNice tip, definitely got me closer.
It’s currently struggling to use get_the_post_thumbnail()I’ve currently got this:
$thumbnailid = (int)$item->object_id; $thumbnail = get_the_post_thumbnail($thumbnailid);
$thumbnailid works well, it gets what I need.
$thumbnail returns a NULL.Even get_the_post_thumbnail(6) returns nothing.
It seems every time I try to define the specific item I need, it closes up on me!
It’s wierd that get_the_post_thumbnail() without anything in brackets returns a thumbnail!Weird!
Any clues?
Forum: Plugins
In reply to: Thumbnail as menu itemStill trying to work this out, it’s been days of trawling through code chasing variables.
Does anyone know where the info about the post/page/CPT is passed into the menu. It seems the menu uses a whole different set of variables and getting any post/page information is next to impossible… any help?Forum: Alpha/Beta/RC
In reply to: How to show the description of the menuAnyone got any ideas on how to do the same thing but instead of displaying the title and description, show the item’s thumbnail?
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
This line show the title, is there any way of doing
$item->thumbnail
or a workaround hack?Forum: Plugins
In reply to: Thumbnail as menu itemI’m guessing this is the section I need to borrow and edit for my use:?
class Walker_Nav_Menu extends Walker { /** * @see Walker::$tree_type * @since 3.0.0 * @var string */ var $tree_type = array( 'post_type', 'taxonomy', 'custom' ); /** * @see Walker::$db_fields * @since 3.0.0 * @todo Decouple this. * @var array */ var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' ); /** * @see Walker::start_lvl() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of page. Used for padding. */ function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul class=\"sub-menu\">\n"; } /** * @see Walker::end_lvl() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param int $depth Depth of page. Used for padding. */ function end_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "$indent</ul>\n"; } /** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth, $args) { global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $class_names = $value = ''; $classes = empty( $item->classes ) ? array() : (array) $item->classes; $classes[] = 'menu-item-' . $item->ID; $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); $class_names = ' class="' . esc_attr( $class_names ) . '"'; $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); $id = strlen( $id ) ? ' id="' . esc_attr( $id ) . '"' : ''; $output .= $indent . '<li' . $id . $value . $class_names .'>'; $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; $item_output = $args->before; $item_output .= '<a'. $attributes .'>'; $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } /** * @see Walker::end_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Page data object. Not used. * @param int $depth Depth of page. Not Used. */ function end_el(&$output, $item, $depth) { $output .= "</li>\n"; } }
If so, is it this following section I would need to edit…
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : ''; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : ''; $item_output = $args->before; $item_output .= '<a'. $attributes .'>'; $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after;
If so, how do I call the thumbnail. I ask because things like the_title() don’t get used so will post_thumbnail() work here?
What do you mean by the walk() method, don’t know where you’re finding this?
Sorry to keep asking. I think I’m closer, very much appreciate your spoon feeding!!
Forum: Plugins
In reply to: Thumbnail as menu itemThanks for this Michael. Thanks for getting back to me.
Could you clarify this, where I should put these items and how I then call the post_thumbnail… ?I’m not familiar with the walker class
Forum: Themes and Templates
In reply to: Is it possible in WordPress?jQuery is very possible in WP. WP has a whole load of output tags and variables that easily drop into any html, jscript etc. I can be fiddly if you don’t know JQuery but there’s plenty of tutorials and resources for image galleries etc out there
Forum: Themes and Templates
In reply to: Where do you save templates to?As in your theme? You should just save these in wp-content/themes/{yourtheme}
Sorry if I missed the point
Forum: Themes and Templates
In reply to: Generating Post Thumbnails as a list on PagesGot it! This is a neat trick for listing posts on a page above ordinary content:
<?php $args = array( 'posts_per_page' => 4, 'post_type' => 'post', ); query_posts($args); if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> [POST PROPERTIES IN HERE] <?php endwhile; ?> <?php endif; ?>
Then make sure you
<?php wp_reset_query(); ?>
Then you can have a normal loop below that.
If someone spots that this is bad practice or will cause trouble in the future, please say but for now, enjoy posting posts on pages!!
Forum: Themes and Templates
In reply to: Generating Post Thumbnails as a list on PagesThanks for that esmi. I’ve had a look through that and tried to implement it into the site I’m working on.
It works for posts but won’t work for the times when I want to mix Posts onto a Page.
I’m using query_posts or the standard loop to call a list of posts, then have a secondary loop to call the page (which is a PAGE rather than a number of posts). It works for listing posts but not pages.
I’ve also tried to rewind_posts(). Again this works for posts but won’t call a page.
Is there something that I can call the page I want that doesn’t affect the loop?
Help!!