Dynamically output a class to an anchor tag depending on what tag is chosen

Sounds like you’d want to use this: http://codex.wordpress.org/Function_Reference/wp_get_object_terms If you’re using a custom taxonomy, add that where it says “post_tag”. unset($tags); foreach(wp_get_object_terms($post->ID, ‘post_tag’) as $tag) : $tags .= ‘ ‘ . $tag->name; endforeach; And then add it to your anchor tag: <a href=”https://wordpress.stackexchange.com/questions/36707/<?php the_permalink(); ?>” title=”View Item” class=”product_view_sm<?php echo $tags; ?>”>..View Item..</a>

Custom Post Type & Custom Menu Walker to append custom class for active post types

When i want to add the classes current-menu-item and current-page-ancestor i always use the wp_nav_menu without any custom walker. I only build my own walker if i want to change lets say the classes to something like “sel” instead. So i add the menu like this: <?php wp_nav_menu( array( ‘theme_location’ => ‘company-menu’, ‘container’ => false, … Read more

How can I display the parts of custom posts?

<?php while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo ‘<div class=”entry-content”>’; the_content(); echo ‘</div>’; echo ‘<div class=”custom-field”>’; echo get_post_meta( get_the_ID(), ‘name’, true ); echo get_post_meta( get_the_ID(), ‘title’, true ); echo get_post_meta( get_the_ID(), ‘bank’, true ); echo ‘</div>’; endwhile; ?> This is how you would display the custom fields below the content. I didn’t test it … Read more

Changed permalink structure of CPT – should I redirect?

I concur that you need to add a redirect. You can do this easily with the following function. I’m sure you will have to tweak it, but it’s a good proof-of-concept. add_action(‘parse_request’, ‘redirect_books_to_fiction’, 0); function redirect_books_to_fiction(){ global $wp; if(preg_match_all(‘~literature\/(.+)/(.+)?~’, $wp->request, $matches)){ $redirect = get_bloginfo(‘siteurl’).”https://wordpress.stackexchange.com/”.str_replace(‘books’, ‘fiction’, $wp->request); wp_redirect($redirect, 301); exit; } } To further answer you … Read more

Problems with 404, .htaccess, permalinks and WordPress custom posts locally on Snow Leopard

You named the custom post type ‘custom_about_post’ not ‘about’. Rename the archive template to archive-custom_about_post.php or better: rename the post type. As a rule of thumb: Avoid underscores in post type names. There are/were some issues, especially with templates. And why do you need a custom post type just for about pages? What’s your goal?