Home › Forums › ACF PRO › Display Image for each entry on Tag Archive › Reply To: Display Image for each entry on Tag Archive
I went in and disabled everything except ACF and Custom Post Type UI (since I’m using this for the custom post type) and the problem is still there. However, it made me think of what I had to do to get the tag archives working in the first place. Apparently there is an issue with WordPress archives grabbing tags from custom posts types, so I had to use this code in my functions.php file:
//Tag Archive
function namespace_add_custom_types( $query ) {
if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
$query->set( 'post_type', array(
'post', 'nav_menu_item', 'sponsors'
));
return $query;
}
}
add_filter( 'pre_get_posts', 'namespace_add_custom_types' );
And, for the heck of it, here are the other custom scripts I’m running in the functions.php file:
/*
* Allows extra HTML items in to the_excerpt instead of stripping them like WordPress does
*/
function theme_t_wp_improved_trim_excerpt($text) {
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text, '<p>,<ul>,<li>,<ol>,<b>,<strong>,<br>,<a>,<br />');
$excerpt_length = 70;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words)> $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'theme_t_wp_improved_trim_excerpt');
//Drop Down Menu for Tags
function drop_tags()
{
echo "<select class=taglist onChange=\"document.location.href=this.options[this.selectedIndex].value;\">";
echo "<option>Select a Category:</option>\n";
foreach (get_tags() as $tag)
{
echo "<option value=\"";
echo get_tag_link($tag->term_id);
echo "\">".$tag->name."</option>\n";
}
echo "</select>";
}
// Custom Footer Menu Walker
class example_nav_walker extends Walker_Nav_Menu {
var $current_menu = null;
var $break_point = 6;
function start_el(&$output, $item, $depth, $args) {
global $wp_query;
if( !isset( $this->current_menu ) )
$this->current_menu = wp_get_nav_menu_object( $args->menu );
if( !isset( $this->break_point ) )
$this->break_point = ceil( $this->current_menu->count / 2 ) + 1;
$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, $args ) );
$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 ) . '"' : '';
if( $this->break_point == $item->menu_order )
$output .= $indent . '</li></ul><ul id=menu-main-menu-2><li' . $id . $value . $class_names .'>';
else
$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 );
}
}
I'm not certain that this is the cause of the conflict, but I figured it would be relevant since it's helping create the archive pages.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.