PHP display sibling pages as a set image - php

I am trying to customise the following code so it displays all sibling pages of the current page, but instead of outputting them as the title, they are output as bulletpoints (styled bulletpoints so an image, 'images/bulletpoint.gif'). I have the following code that displays them as the names, but can't seem to customise them to display as an image. Any ideas?
Many thanks
<ul class="subnav_right">
<?php
global $post;
$current_page_parent = ( $post->post_parent ? $post->post_parent : $post->ID );
wp_list_pages( array(
'title_li' => '',
'child_of' => $current_page_parent,
'depth' => '1' )
);
?>
</ul>

You can customize using walker.I have done it using walker. check following code:
Walker Class:
class Custom_Walker extends Walker_Page {
function start_el( &$output, $page, $depth, $args, $current_page = 0 ) {
if ( $depth )
$indent = str_repeat("\t", $depth);
else
$indent = '';
extract($args, EXTR_SKIP);
$css_class = array('page_item', 'page-item-'.$page->ID);
if ( !empty($current_page) ) {
$_current_page = get_post( $current_page );
if ( in_array( $page->ID, $_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';
}
elseif ( $page->ID == get_option('page_for_posts') ) {
$css_class[] = 'current_page_parent';
}
$css_class = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );
$icon_class = get_post_meta($page->ID, 'icon_class', true); //Retrieve stored icon class from post meta
$output .= $indent . '<li class="' . $css_class . '">';
$output .= '<a href="' . get_permalink($page->ID) . '">' . $link_before;
if($icon_class){ //Test if $icon_class exists
$output .= '<span class="' . $icon_class . '"></span>'; //If it exists output a span with the $icon_class attached to it
}
if($depth!=0){
$output .= apply_filters( 'the_title', '', $page->ID );
}else {
$output .= apply_filters( 'the_title', $page->post_title, $page->ID );
}
$output .= $link_after . '</a>';
if ( !empty($show_date) ) {
if ( 'modified' == $show_date )
$time = $page->post_modified;
else
$time = $page->post_date;
$output .= " " . mysql2date($date_format, $time);
}
}
}
Pass walker in argumnent like:
wp_list_pages( array( 'title_li' => '',
'child_of' => $current_page_parent,
'depth' => '1',
'walker' => new Custom_Walker())
);

Related

base64 image not displaying in img tag PHP

I have added a function into my child theme to override the original function. This functions purpose is to display the products meta data in a list below the product.
The only part i can get past is the base64 image.
My current code is :
function wc_display_item_meta( $item, $args = array() ) {
$strings = array();
$html = '';
$args = wp_parse_args(
$args,
array(
'before' => '<ul class="wc-item-meta"><li>',
'after' => '</li></ul>',
'separator' => '</li><li>',
'echo' => true,
'autop' => false,
'label_before' => '<strong class="wc-item-meta-label">',
'label_after' => ':</strong> ',
)
);
foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
$value = $args['autop'] ? wp_kses_post( $meta->display_value ) : wp_kses_post( make_clickable( trim( $meta->display_value ) ) );
$key = wp_kses_post( $meta->display_key );
if($key === "Tie Preview"){
$b64 = explode(',', $value);
$image = base64_decode($b64[1]);
$strings[] = $args['label_before'] . wp_kses_post( $meta->display_key ) . $args['label_after'] . '<img src="data:image/png;base64,' . $image . '" />';
}else{
$strings[] = $args['label_before'] . wp_kses_post( $meta->display_key ) . $args['label_after'] . $value;
}
}
if ( $strings ) {
$html = $args['before'] . implode( $args['separator'], $strings ) . $args['after'];
}
$html = apply_filters( 'woocommerce_display_item_meta', $html, $item, $args );
if ( $args['echo'] ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $html;
} else {
return $html;
}
}
As you can see in the image below the image tag appears but the base64 image doesn't display.
Here is a screenshot of the data url loaded in a browser:
Has anyone else come up with this issue.
I have figured out the issue!!!!
instead of the <img> i replaced it with and <a>. I decided to do this as i could view the tool tip to see the out of the href attribute was.
as you can see somehow there is a <p> being added. iv now taken the value and used substr() to remove the <p> at the front and end of the string.
My new code now looks like so:
function wc_display_item_meta( $item, $args = array() ) {
$strings = array();
$html = '';
$args = wp_parse_args(
$args,
array(
'before' => '<ul class="wc-item-meta"><li>',
'after' => '</li></ul>',
'separator' => '</li><li>',
'echo' => true,
'autop' => false,
'label_before' => '<strong class="wc-item-meta-label">',
'label_after' => ':</strong> ',
)
);
foreach ( $item->get_all_formatted_meta_data() as $meta_id => $meta ) {
$value = $args['autop'] ? wp_kses_post( $meta->display_value ) : wp_kses_post( make_clickable( trim( $meta->display_value ) ) );
$key = wp_kses_post( $meta->display_key );
if($key === "Tie Preview"){
$sub1 = substr($value, 3);
$sub2 = substr($sub1, 0, -4);
$strings[] = $args['label_before'] . wp_kses_post( $meta->display_key ) . $args['label_after'] . '<img src="' . $sub2 . '" />' . "<a href='" . $sub2 . "' >click here</a>";
}else{
$strings[] = $args['label_before'] . wp_kses_post( $meta->display_key ) . $args['label_after'] . $value;
}
}
if ( $strings ) {
$html = $args['before'] . implode( $args['separator'], $strings ) . $args['after'];
}
$html = apply_filters( 'woocommerce_display_item_meta', $html, $item, $args );
if ( $args['echo'] ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $html;
} else {
return $html;
}
}

wp_nav_menu_items add custom item 2nd, not last

I have this function that adds menu items to my menu...My question is, is it possible to have them 2nd in the menu and not last?
function ur_add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'primary') {
$items .= '<li>Blog Log Out</li>';
} elseif ( ! is_user_logged_in() && $args->theme_location == 'primary' ) {
$items .= '<li>Blog Registration</li>';
$items .= '<li>Blog Log In</li>';
}
return $items;
}
add_filter( 'wp_nav_menu_items', 'ur_add_loginout_link', 10, 2 );
Yes, but you have to make use of a slightly modified version of the Walker_Nav_Menu class.
Something like this:
class Custom_Menu_Walker extends Walker_Nav_Menu {
private $counter;
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth );
$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
$output .= $indent . '<li' . $id . $class_names .'>';
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
$title = apply_filters( 'the_title', $item->title, $item->ID );
$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . $title . $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
if ( $item->menu_item_parent === '0' ) {
$this->counter++;
}
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
if ( ( $item->menu_item_parent === '0' ) && ( $this->counter === 1 ) ) {
$output .= "</li>{$n}";
if ( is_user_logged_in() && $args->theme_location == 'primary' ) {
$output .= '<li>Blog Log Out</li>{$n}';
} elseif ( ! is_user_logged_in() && $args->theme_location == 'primary' ) {
$output .= '<li>Blog Registration</li>{$n}';
$output .= '<li>Blog Log In</li>{$n}';
}
} else {
$output .= "</li>{$n}";
}
}
}
Put this code in a file and then include it in your theme's functions.php
Then you have to add the walker argument wherever you are outputting the menu:
// Call the primary navigation menu
wp_nav_menu( array(
'theme_location' => 'primary', // Location
'container' => 'nav', // Set the container html tag
'container_class' => 'nav', // Set the class of the container or set to false if you dont need a class specified
'walker' => new Custom_Menu_Walker(), // Make use of the walker
) );

Wordpress 'Our Team' Plugin

I currently have the 'Our Team' plugin installed to display team members.
At the moment, the staff description (that appears in the WISYWIG editor area), is pulled through onto the team page along with all the other staff details.
As there is quite a bit of text for each, i would like to have it so that there is just a 'Read about me' link, and the description text appears in a lightbox instead.
I already have a Lightbox plugin in use on the website (WP Lightbox 2), but just need to know how i can change the 'Our Team' template file so that it displays the link rather than the whole block of text.
Below is the 'woothemes-our-team-template.php' file:
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! function_exists( 'woothemes_get_our_team' ) ) {
/**
* Wrapper function to get the team members from the Woothemes_Our_Team class.
* #param string/array $args Arguments.
* #since 1.0.0
* #return array/boolean Array if true, boolean if false.
*/
function woothemes_get_our_team ( $args = '' ) {
global $woothemes_our_team;
return $woothemes_our_team->get_our_team( $args );
} // End woothemes_get_our_team()
}
/**
* Enable the usage of do_action( 'woothemes_our_team' ) to display team members within a theme/plugin.
*
* #since 1.0.0
*/
add_action( 'woothemes_our_team', 'woothemes_our_team' );
if ( ! function_exists( 'woothemes_our_team' ) ) {
/**
* Display or return HTML-formatted team members.
* #param string/array $args Arguments.
* #since 1.0.0
* #return string
*/
function woothemes_our_team ( $args = '' ) {
global $post, $more;
$defaults = apply_filters( 'woothemes_our_team_default_args', array(
'limit' => 12,
'per_row' => null,
'orderby' => 'menu_order',
'order' => 'DESC',
'id' => 0,
'slug' => null,
'display_author' => true,
'display_additional' => true,
'display_avatar' => true,
'display_url' => true,
'display_twitter' => true,
'display_author_archive' => true,
'display_role' => true,
'contact_email' => true,
'tel' => true,
'effect' => 'fade', // Options: 'fade', 'none'
'pagination' => false,
'echo' => true,
'size' => 250,
'title' => '',
'before' => '<div class="widget widget_woothemes_our_team">',
'after' => '</div>',
'before_title' => '<h2>',
'after_title' => '</h2>',
'category' => 0
) );
$args = wp_parse_args( $args, $defaults );
// Allow child themes/plugins to filter here.
$args = apply_filters( 'woothemes_our_team_args', $args );
$html = '';
do_action( 'woothemes_our_team_before', $args );
// The Query.
$query = woothemes_get_our_team( $args );
// The Display.
if ( ! is_wp_error( $query ) && is_array( $query ) && count( $query ) > 0 ) {
$class = '';
if ( is_numeric( $args['per_row'] ) ) {
$class .= ' columns-' . intval( $args['per_row'] );
}
if ( 'none' != $args['effect'] ) {
$class .= ' effect-' . $args['effect'];
}
$html .= $args['before'] . "\n";
if ( '' != $args['title'] ) {
$html .= html_entity_decode( $args['before_title'] ) . esc_html( $args['title'] ) . html_entity_decode( $args['after_title'] ) . "\n"; }
$html .= '<div class="team-members component' . esc_attr( $class ) . '">' . "\n";
// Begin templating logic.
$tpl = '<div itemscope itemtype="http://schema.org/Person" class="%%CLASS%%">%%AVATAR%% %%TITLE%% <div id="team-member-%%ID%%" class="team-member-text" itemprop="description">%%TEXT%% %%AUTHOR%%</div></div>';
$tpl = apply_filters( 'woothemes_our_team_item_template', $tpl, $args );
$count = 0;
foreach ( $query as $post ) {
$count++;
$template = $tpl;
$css_class = apply_filters( 'woothemes_our_team_member_class', $css_class = 'team-member' );
if ( ( is_numeric( $args['per_row'] ) && ( 0 == ( $count - 1 ) % $args['per_row'] ) ) || 1 == $count ) { $css_class .= ' first'; }
if ( ( is_numeric( $args['per_row'] ) && ( 0 == $count % $args['per_row'] ) ) ) { $css_class .= ' last'; }
// Add a CSS class if no image is available.
if ( isset( $post->image ) && ( '' == $post->image ) ) {
$css_class .= ' no-image';
}
setup_postdata( $post );
$title = '';
$title_name = '';
// If we need to display the title, get the data
if ( ( get_the_title( $post ) != '' ) && true == $args['display_author'] ) {
$title .= '<h3 itemprop="name" class="member">';
if ( true == $args['display_url'] && '' != $post->url && apply_filters( 'woothemes_our_team_member_url', true ) ) {
$title .= '<a href="' . esc_url( $post->url ) . '">' . "\n";
}
$title_name = get_the_title( $post );
$title .= $title_name;
if ( true == $args['display_url'] && '' != $post->url && apply_filters( 'woothemes_our_team_member_url', true ) ) {
$title .= '</a>' . "\n";
}
$title .= '</h3><!--/.member-->' . "\n";
$member_role = '';
if ( true == $args['display_role'] && isset( $post->byline ) && '' != $post->byline && apply_filters( 'woothemes_our_team_member_role', true ) ) {
$member_role .= ' <p class="role" itemprop="jobTitle">' . $post->byline . '</p><!--/.excerpt-->' . "\n";
}
$title .= apply_filters( 'woothemes_our_team_member_fields_display', $member_role );
}
// Templating engine replacement.
$template = str_replace( '%%TITLE%%', $title, $template );
$author = '';
$author_text = '';
$user = $post->user_id;
// If we need to display the author, get the data.
if ( true == $args['display_additional'] ) {
$author .= '<ul class="author-details">';
$member_fields = '';
if ( true == $args['display_author_archive'] && apply_filters( 'woothemes_our_team_member_user_id', true ) ) {
// User didn't select an item from the autocomplete list
// Let's try to get the user from the search query
if ( 0 == $post->user_id && '' != $post->user_search ) {
$user = get_user_by( 'slug', $post->user_search );
if ( $user ) {
$user = $user->ID;
}
}
if ( 0 != $user ) {
$member_fields .= '<li class="our-team-author-archive" itemprop="url">' . sprintf( __( 'Read posts by %1$s', 'our-team-by-woothemes' ), get_the_title() ) . '</li>' . "\n";
}
}
if ( true == $args['contact_email'] && '' != $post->contact_email && apply_filters( 'woothemes_our_team_member_contact_email', true ) ) {
$member_fields .= '<li class="our-team-contact-email" itemprop="email">' . __( 'Email me ', 'our-team-by-woothemes' ) . '</li>';
}
if ( true == $args['tel'] && '' != $post->tel && apply_filters( 'woothemes_our_team_member_tel', true ) ) {
$call_protocol = apply_filters( 'woothemes_our_team_call_protocol', $protocol = 'tel' );
$member_fields .= '<li class="our-team-tel" itemprop="telephone"><span>' . __( 'Tel: ', 'our-team-by-woothemes' ) . '</span>' . esc_html( $post->tel ) . '</li>';
}
if ( true == $args['display_twitter'] && '' != $post->twitter && apply_filters( 'woothemes_our_team_member_twitter', true ) ) {
$member_fields .= '<li class="our-team-twitter" itemprop="contactPoint">Follow #' . esc_html( $post->twitter ) . '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li>' . "\n";
}
$author .= apply_filters( 'woothemes_our_member_fields_display', $member_fields );
$author .= '</ul>';
// Templating engine replacement.
$template = str_replace( '%%AUTHOR%%', $author, $template );
} else {
$template = str_replace( '%%AUTHOR%%', '', $template );
}
// Templating logic replacement.
$template = str_replace( '%%ID%%', get_the_ID(), $template );
$template = str_replace( '%%CLASS%%', esc_attr( $css_class ), $template );
if ( isset( $post->image ) && ( '' != $post->image ) && true == $args['display_avatar'] ) {
$template = str_replace( '%%AVATAR%%', '<figure itemprop="image">' . $post->image . '</figure>', $template );
} else {
$template = str_replace( '%%AVATAR%%', '', $template );
}
// Remove any remaining %%AVATAR%% template tags.
$template = str_replace( '%%AVATAR%%', '', $template );
$real_more = $more;
$more = 0;
$content = apply_filters( 'woothemes_our_team_content', wpautop( get_the_content( __( 'Read full biography...', 'our-team-by-woothemes' ) ) ), $post );
$more = $real_more;
// Display bio if Team Member is mapped to a user on this site.
if ( apply_filters( 'woothemes_our_team_display_bio', true ) && 0 != $user ) {
if ( '' != get_the_author_meta( 'description', $user ) ) {
$content = wpautop( get_the_author_meta( 'description', $user ) );
}
}
$template = str_replace( '%%TEXT%%', $content, $template );
// filter the individual team member html
$template = apply_filters( 'woothemes_our_team_member_html', $template, $post );
// Assign for output.
$html .= $template;
}
wp_reset_postdata();
if ( $args['pagination'] == true && count( $query ) > 1 && $args['effect'] != 'none' ) {
$html .= '<div class="pagination">' . "\n";
$html .= '' . apply_filters( 'woothemes_our_team_prev_btn', '← ' . __( 'Previous', 'our-team-by-woothemes' ) ) . '' . "\n";
$html .= '' . apply_filters( 'woothemes_our_team_next_btn', __( 'Next', 'our-team-by-woothemes' ) . ' →' ) . '' . "\n";
$html .= '</div><!--/.pagination-->' . "\n";
}
$html .= '</div><!--/.team-members-->' . "\n";
$html .= $args['after'] . "\n";
}
// Allow child themes/plugins to filter here.
$html = apply_filters( 'woothemes_our_team_html', $html, $query, $args );
if ( $args['echo'] != true ) {
return $html;
}
// Should only run is "echo" is set to true.
echo $html;
do_action( 'woothemes_our_team_after', $args ); // Only if "echo" is set to true.
} // End woothemes_our_team()
}
if ( ! function_exists( 'woothemes_our_team_shortcode' ) ) {
/**
* The shortcode function.
* #since 1.0.0
* #param array $atts Shortcode attributes.
* #param string $content If the shortcode is a wrapper, this is the content being wrapped.
* #return string Output using the template tag.
*/
function woothemes_our_team_shortcode ( $atts, $content = null ) {
$args = (array)$atts;
$defaults = array(
'limit' => 12,
'per_row' => null,
'orderby' => 'menu_order',
'order' => 'DESC',
'id' => 0,
'slug' => null,
'display_author' => true,
'display_additional' => true,
'display_avatar' => true,
'display_url' => true,
'display_author_archive' => true,
'display_twitter' => true,
'display_role' => true,
'effect' => 'fade', // Options: 'fade', 'none'
'pagination' => false,
'echo' => true,
'size' => 250,
'category' => 0,
'title' => '',
'before_title' => '<h2>',
'after_title' => '</h2>'
);
$args = shortcode_atts( $defaults, $atts );
// Make sure we return and don't echo.
$args['echo'] = false;
// Fix integers.
if ( isset( $args['limit'] ) ) {
$args['limit'] = intval( $args['limit'] );
}
if ( isset( $args['size'] ) && ( 0 < intval( $args['size'] ) ) ) {
$args['size'] = intval( $args['size'] );
}
if ( isset( $args['category'] ) && is_numeric( $args['category'] ) ) {
$args['category'] = intval( $args['category'] );
}
// Fix booleans.
foreach ( array( 'display_author', 'display_additional', 'display_url', 'display_author_archive', 'display_twitter', 'display_role', 'pagination', 'display_avatar' ) as $k => $v ) {
if ( isset( $args[$v] ) && ( 'true' == $args[$v] ) ) {
$args[$v] = true;
} else {
$args[$v] = false;
}
}
return woothemes_our_team( $args );
} // End woothemes_our_team_shortcode()
}
add_shortcode( 'woothemes_our_team', 'woothemes_our_team_shortcode' );
if ( ! function_exists( 'woothemes_our_team_content_default_filters' ) ) {
/**
* Adds default filters to the "woothemes_our_team_content" filter point.
* #since 1.0.0
* #return void
*/
function woothemes_our_team_content_default_filters () {
add_filter( 'woothemes_our_team_content', 'do_shortcode' );
} // End woothemes_our_team_content_default_filters()
add_action( 'woothemes_our_team_before', 'woothemes_our_team_content_default_filters' );
}
add_filter( 'the_content', 'woothemes_our_team_content' );
/**
* Display team member data on single / archive pages
* #since 1.4.0
* #return $content the post content
*/
function woothemes_our_team_content( $content ) {
global $post;
$team_member_email = esc_attr( get_post_meta( $post->ID, '_gravatar_email', true ) );
$user = esc_attr( get_post_meta( $post->ID, '_user_id', true ) );
$user_search = esc_attr( get_post_meta( $post->ID, '_user_search', true ) );
$twitter = esc_attr( get_post_meta( $post->ID, '_twitter', true ) );
$role = esc_attr( get_post_meta( $post->ID, '_byline', true ) );
$url = esc_attr( get_post_meta( $post->ID, '_url', true ) );
$tel = esc_attr( get_post_meta( $post->ID, '_tel', true ) );
$contact_email = esc_attr( get_post_meta( $post->ID, '_contact_email', true ) );
if ( 'team-member' == get_post_type() ) {
$team_member_gravatar = '';
$team_member_role = '';
$member_fields = '';
$author = '';
if ( isset( $team_member_email ) && ( '' != $team_member_email ) ) {
$team_member_gravatar = '<figure itemprop="image">' . get_avatar( $team_member_email, 250 ) . '</figure>';
}
if ( isset( $role ) && '' != $role && apply_filters( 'woothemes_our_team_member_role', true ) ) {
$team_member_role .= ' <p class="role" itemprop="jobTitle">' . $role . '</p>' . "\n";
}
$author .= '<ul class="author-details">';
if ( apply_filters( 'woothemes_our_team_member_user_id', true ) ) {
if ( 0 == $user && '' != $user_search ) {
$user = get_user_by( 'slug', $user_search );
if ( $user ) {
$user = $user;
}
}
if ( 0 != $user ) {
$member_fields .= '<li class="our-team-author-archive" itemprop="url">' . sprintf( __( 'Read posts by %1$s', 'woothemes' ), get_the_title() ) . '</li>' . "\n";
}
}
if ( '' != $tel && apply_filters( 'woothemes_our_team_member_contact_email', true ) ) {
$member_fields .= '<li class="our-team-contact-email" itemprop="email">' . __( 'Email ', 'our-team-by-woothemes' ) . get_the_title() . '</li>';
}
if ( '' != $tel && apply_filters( 'woothemes_our_team_member_tel', true ) ) {
$call_protocol = apply_filters( 'woothemes_our_team_call_protocol', $protocol = 'tel' );
$member_fields .= '<li class="our-team-tel" itemprop="telephone"><span>' . __( 'Tel: ', 'our-team-by-woothemes' ) . '</span>' . $tel . '</li>';
}
if ( '' != $twitter && apply_filters( 'woothemes_our_team_member_twitter', true ) ) {
$member_fields .= '<li class="our-team-twitter" itemprop="contactPoint">Follow #' . esc_html( $twitter ) . '<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?"http":"https";if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document, "script", "twitter-wjs");</script></li>' . "\n";
}
$author .= apply_filters( 'woothemes_our_member_fields_display', $member_fields );
$author .= '</ul>';
return $team_member_gravatar . $team_member_role . $content . $author;
} else {
return $content;
}
}
You can filter the template:
function so_27863277_our_team_template( $tpl, $args ){
$tpl = '<div itemscope itemtype="http://schema.org/Person" class="%%CLASS%%">%%AVATAR%% %%TITLE%% Read About Me<div id="team-member-%%ID%%" class="team-member-text" itemprop="description">%%TEXT%% %%AUTHOR%%</div></div>';
return $tpl;
}
add_filter( 'woothemes_our_team_item_template', 'so_27863277_our_team_template', 10, 2 );
Then by default, you might also want to style the team-member-text div so that it is hidden.
.team-member-text{ display: none; }
I'm not sure how to make it work with your particular lightbox plugin so you will have to adapt that part yourself.

Wordpress wp_nav_menu nav > a

I'm actually working on a website and i develop a theme.
I've a problem with the wp_nav_menu.
I've a navigation like this :
<nav>
item 1
item 2
item 3
item 4
</nav>
And i would like this menu:
<nav>
item 1
item 2
item 2
item 1
</nav>
if you preferer , add a custom class for each .
Here are the parameters of the current menu. No function in function.php
<?php
$menuParameters = array(
'theme_location' => 'primary',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
);
echo strip_tags(wp_nav_menu( $menuParameters ), '<a>' );
?>
Have u got any solution ?
I specify that the classes in the administration > navigation don't work
In your backend go to Appearance -> Menus. In the top right corner there is a tab called Screen Options, there in 'Show advanced menu properties' tick CSS classes, that will enable you to add adittional class to your menu items.
You need the custom nav menu walker to achieve this.
First, you need to remove the <ul>, </ul>, <li>, and </li> tags on the walker,
and then move the css classes to the <a> tag.
Below is the walker i've tried, paste this on functions.php:
class Custom_Walker_Nav_Menu extends Walker_Nav_Menu {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
$output .= "{$n}{$indent}{$n}";
}
public function end_lvl( &$output, $depth = 0, $args = array() ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = str_repeat( $t, $depth );
$output .= "{$n}";
}
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$indent = ( $depth ) ? str_repeat( $t, $depth ) : '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$classes[] = 'menu-item-' . $item->ID;
$args = apply_filters( 'nav_menu_item_args', $args, $item, $depth );
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
$atts = array();
$atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : '';
$atts['target'] = ! empty( $item->target ) ? $item->target : '';
$atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : '';
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts['class'] = ! empty( $class_names ) ? $class_names : '';
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
$attributes = '';
foreach ( $atts as $attr => $value ) {
if ( ! empty( $value ) ) {
$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
$attributes .= ' ' . $attr . '="' . $value . '"';
}
}
$title = apply_filters( 'the_title', $item->title, $item->ID );
$title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth );
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . $title . $args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
public function end_el( &$output, $item, $depth = 0, $args = array() ) {
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
$t = '';
$n = '';
} else {
$t = "\t";
$n = "\n";
}
$output .= "{$n}";
}
}
And set your wp_nav_menu args:
<?php
$menuParameters = array(
'theme_location' => 'primary',
'container' => false,
'echo' => false,
'items_wrap' => '%3$s',
'depth' => 0,
'walker' => new Custom_Walker_Nav_Menu()
);
// no need to strip tags since the custom walker already trimmed it
echo wp_nav_menu( $menuParameters );
?>
Don't forget to set css class in the Appearance -> Menus

If there is no thumbnail display "no thumbnail"

Below is a Wordpress function that pulls in a thumbnail image for a menu. How do I add an if/else to display "No thumbail" if there is no thumbail?
I have tried:
$item_output .= apply_filters( 'menu_item_thumbnail' , ( !isset( $args->thumbnail ) && $args->thumbnail ) ) ? 'no thumbnail' : '';
But this had no effect. Sorry if this is a dumb question, but I don't know PHP.
The function:
class Menu_With_Description extends Walker_Nav_Menu {
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
// get user defined attributes for thumbnail images
$attr_defaults = array( 'class' => 'nav_thumb' , 'alt' => esc_attr( $item->attr_title ) , 'title' => esc_attr( $item->attr_title ) );
$attr = isset( $args->thumbnail_attr ) ? $args->thumbnail_attr : '';
$attr = wp_parse_args( $attr , $attr_defaults );
$item_output = $args->before;
// thumbnail image output
$item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '<a' . $attributes . '>' : '';
$item_output .= apply_filters( 'menu_item_thumbnail' , ( isset( $args->thumbnail ) && $args->thumbnail ) ? get_the_post_thumbnail( $item->object_id , ( isset( $args->thumbnail_size ) ) ? $args->thumbnail_size : 'thumbnail' , $attr ) : '' , $item , $args , $depth );
$item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '</a>' : '';
// menu link output
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
$item_output .= '</a>';
// menu description output based on depth
$item_output .= ( $args->desc_depth >= $depth ) ? '<br /><span class="sub">' . $item->description . '</span>' : '';
// close menu link anchor
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
This applies the above to my menu:
add_filter( 'wp_nav_menu_args' , 'my_add_menu_descriptions' );
function my_add_menu_descriptions( $args ) {
if ( $args['theme_location'] == 'my_menu' ) {
$args['walker'] = new Menu_With_Description;
$args['desc_depth'] = 0;
$args['thumbnail'] = true;
$args['thumbnail_link'] = true;
$args['thumbnail_size'] = 'homeboxes';
$args['thumbnail_attr'] = array( 'class' => 'nav_thumb my_thumb' , 'alt' => 'test' , 'title' => 'test' );
}
return $args;
}
Don't modify the Class. Use this filter instead:
add_filter( 'menu_item_thumbnail', 'so_13368049_change_thumb', 10, 4 );
function so_13368049_change_thumb( $thumb, $item , $args , $depth )
{
if( '' == $thumb )
return 'No thumbnail';
return $thumb;
}
And if you were to modify the Class, it should be like this:
('NO THUMBNAIL' instead of '')
$item_output .= apply_filters( 'menu_item_thumbnail' , ( isset( $args->thumbnail ) && $args->thumbnail ) ? get_the_post_thumbnail( $item->object_id , ( isset( $args->thumbnail_size ) ) ? $args->thumbnail_size : 'thumbnail' , $attr ) : 'NO THUMBNAIL' , $item , $args , $depth );

Categories