Site logo

Archived topic

Display Issue on Category Archive Page

7 replies · Started by Dave on April 15, 2021

Viewing posts 1–8 of 8

I am having an issue with the formatting of the layout on my category pages. It seems the pages are not adopting the formatting for some reason and that is throwing the whole page off.
Any help would be appreciated.

Cheers,

Dave

Hi there,

what code / plugin did you use to include the Pages within that category ?

This is the code I used:
function add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_taxonomies_to_pages' );
if ( ! is_admin() ) {
add_action( 'pre_get_posts', 'category_and_tag_archives' );

}
function category_and_tag_archives( $wp_query ) {
$my_post_array = array('post','page');

if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) )
$wp_query->set( 'post_type', $my_post_array );

if ( $wp_query->get( 'tag' ) )
$wp_query->set( 'post_type', $my_post_array );
}

That kind of worked. It stopped the spacing issue but it has no styling.
Any ideas?

Cheers,

Dave

Is there a specific page we should be looking at or compare to?

I'm looking at the /category/mexico/ and it looks good to me.

Yes, The page is in the private info. I have also attached a screenshot.
In the screenshot you can see that the Page Mexico Travel Guide is missing all of the styling that the other posts have beside it.

cheers,

Dave

You're CSS for the styling is targeting the .post element - when these are .page.
Change this CSS:

.archive .post .inside-article {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  box-shadow: rgba(23,43,99,.25) 0 7px 9px !important;
}

.archive .post .inside-article {
  padding-right: 20px;
  padding-top: 50px;
  padding-left: 20px;
  padding-bottom: 0px;
}

to

.archive .generate-columns .inside-article {
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  box-shadow: rgba(23,43,99,.25) 0 7px 9px !important;
}

.archive .generate-columns .inside-article {
  padding-right: 20px;
  padding-top: 50px;
  padding-left: 20px;
  padding-bottom: 0px;
}

the .generate-columns class is common to all article elements in the columns.

This archived topic is closed to new replies.