Community Forums › Forums › Archived Forums › Design Tips and Tricks › inserting a taxonomy archive page from post
Tagged: archive, Custom Post Type, featured images, images, taxonomies, taxonomy
- This topic has 1 reply, 2 voices, and was last updated 10 years, 7 months ago by Susan.
-
AuthorPosts
-
October 25, 2013 at 2:17 pm #68904thoughtwellMember
For my taxonomy archive page in my theme (genesis 2.0 theme) I have found a way to insert an image based on a function hooked into 'genesis_after_header' and it works if you only have one custom post type in the taxonomy. However, when you add more custom post types to this taxonomy, the image goes away, just leaving the page as it would appear as if the function did not exist (in other words, no image at all from either post.)
The idea is to achieve a featured image for this taxonomy type. The featured image is to be pulled from the first post listed in the loop on that page.
Can anyone look at this code and suggest a way to do this that will output the featured image from the first post into the taxonomy archive page when you have multiple custom post types in the taxonomy? This has been kind of hacked together w/ my noobish php skill and pulling parts from various online tutorials along other lines that I kinda 'home-brewed' into this function that does (sorta) what I would like it to w/ the exception it breaks when more that one post is included in the taxonomy archive page's loop. Perhaps someone can suggest a more semantic way?
Code excerpt from my taxonomy archive page, "taxonomy-smt_equipment_family.php":
<?php
/**
* The Equipment Families Taxonomy Page
*/add_action( 'genesis_after_header', 'insert_stage_thumb');
function insert_stage_thumb() {
if(has_post_thumbnail($post->ID)) {
$image = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?>
<div class="stage_thumb" style="background: url('<?php echo $image[0]; ?>') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; width: 100%; height: 400px; height: 40rem;">
</div>
<?php
}
}/** Remove the post info function */
remove_action( 'genesis_before_post_content', 'genesis_post_info' );//* Remove the entry meta in the entry header (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );/** Remove the author box on single posts */
remove_action( 'genesis_after_post', 'genesis_do_author_box_single' );/** Remove the post meta function */
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );/** Remove the comments template */
remove_action( 'genesis_after_post', 'genesis_get_comments_template' );remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
add_action( 'genesis_sidebar', 'smtwp_do_sidebar' ); //add an action hook to call the function for my custom sidebar
//Function to output my custom sidebar
function smtwp_do_sidebar() {
dynamic_sidebar( 'product-menu' );
}genesis();
http://localhostFebruary 12, 2014 at 7:31 pm #90064SusanModeratorSince it's been a while since you posted your question, I hope you got your issue resolved.
If not, please report back to me, and I will escalate to try to get someone to assist you.
Thanks!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.