Community Forums › Forums › Archived Forums › General Discussion › Getting tag.php archive page(s) to mimic custom category.php page(s)
Tagged: custom tag archive, tag archive, tag.php
- This topic has 1 reply, 2 voices, and was last updated 7 years, 1 month ago by Susan.
-
AuthorPosts
-
November 10, 2016 at 7:37 am #195981TurboPoet94Member
Hi,
I have a design spec for category and tag archive pages that calls for the most recent post to appear at the top of the archive page - basically a "featured post" type design treatment (i.e. title, featured img, excerpt, etc. - broken out from the rest of the normal list of posts).
I was able to tackle that for the category.php (overcoming all sorts of issues, including pagination and offset).
Here's my problem - I want to do exactly what I did for the category.php, but do it for tag.php. But I cannot find the right way to do the following:
1) identify which tag archive page I am on (i.e. tag X)
2) pass this tag info into a custom query and present the results
3) then display the rest of the posts for tag X simple by going back into the normal query and having genesis() do the restAll of this is currently happening on my category.php (I make the pagination adjustments in functions.php).
Below is my code for category.php. I've tried a slew of things - all mangled by yours truly - to modify this code for tags, rather than categories, but am just hitting dead end after dead end.
Can someone please look over and provide any insight into how to modify it to work for tags as tag.php?
TIA,
Tom B.
////////////////////////////////////////////////////////////////////////////////
<?php
/**
* Genesis Framework.
*
* Template: Category
* Ammended Template within news-pro theme
*
* @package Genesis\Templates
* @author StudioPress
* @license GPL-2.0+
* @link http://my.studiopress.com/themes/genesis/
*///////////////////////////////////////////////////////////////
if ( !is_paged() ) {
if (is_category()) {
$category = get_the_category();
$mycat = $category[0]->category_nicename;// Define custom query parameters
$custom_query_args = array(
'category_name' => $category[0]->category_nicename,
'showposts' => 1,
);}
// Get current page and append to custom query parameters array
//$custom_query_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;// Instantiate custom query
$custom_query = new WP_Query( $custom_query_args );// Pagination fix
$temp_query = $wp_query;
$wp_query = NULL;
$wp_query = $custom_query;// Output custom query loop
if ( $custom_query->have_posts() ) :
while ( $custom_query->have_posts() ) :
//* Add the before header ad space and secondary navigation
$custom_query->the_post();
// Loop output goes here
add_action( 'genesis_after_header', 'be_category_featured_post', 10);
function be_category_featured_post() { ?>
<div class="cat-featured-post">
<div class="cat-featured-post-wrap">
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<div class="cat-latest-story">
Latest Story
</div>
<div class="cat-feat-post-thumbnail">
<?php
echo get_the_post_thumbnail( null, 'home-top');
?>
</div>
<div class="cat-feat-post-titles">
<h1>"><?php the_title(); ?></h1>
<div class="cat-feat-post-excerpt">
<?php the_excerpt(); ?>
</div>
</div>
</div>
</div>
</div>
<?php }
endwhile;
endif;
// Reset postdata
wp_reset_postdata();// Reset main query object
$wp_query = NULL;
$wp_query = $temp_query;
}//* Remove the entry footer markup (requires HTML5 theme support)
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );//* Remove the entry meta in the entry footer (requires HTML5 theme support)
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );//* Customize the post info function
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
if ( is_archive () ) {
$post_info = '[post_author_posts_link]';
return $post_info;
}
}//* Remove the entry title (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
add_action ('genesis_entry_content', 'genesis_do_post_title', 9);//* Remove the entry header markup (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
add_action ('genesis_entry_content', 'genesis_post_info', 9);genesis();
February 19, 2017 at 10:31 am #201578SusanModeratorAs you posted this a while back, I hope you were able to get your issue resolved.
If not, you might want to ask over at the GenesisWP Facebook Group, or Slack Group, where there is a larger audience of people responding to questions.
If your issue is resolved, please mark it "resolved", so that it can be closed.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.