[Theme: Gateway] Help with custom post types
-
Hi everybody!
I run an architecture magazine, and every other day we invite illustrators to draw something for our site. These posts consist on just an image and a few lines of text for the credits, etc. The thing is, the Gateway theme has a wide sidebar, and the image couldn’t be appreciated fully.
So I created a child theme, and in the functions.php I added this:function childtheme_formats(){ add_theme_support( 'post-formats', array( 'viernes') ); } add_action( 'after_setup_theme', 'childtheme_formats', 11 ); function remove_more_link_scroll( $link ) { $link = preg_replace( '|#more-[0-9]+|', '', $link ); return $link; }
As a result, I now have a custom post type called ‘viernes’ for these image posts. I also created a single-viernes.php file and in it I wrote this:
<?php /** * The template for displaying all VIERNES posts. * */ get_header(); ?> <div class="row"> <div id="primary" class="content-area"> <div class="large-12 columns"> <main id="main" class="site-main" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'template-parts/content', 'single' ); ?> <?php gateway_post_nav(); ?> <hr> <?php // If comments are open or we have at least one comment, load up the comment template if ( comments_open() || get_comments_number() ) : comments_template(); endif; ?> <?php endwhile; // end of the loop. ?> </main><!-- #main --> </div><!-- .large-12 --> </div><!-- #primary --> </div><!-- .row --> <?php get_footer(); ?>
Now I have a custom post type AND a full width template for those posts. But these custom posts didn’t show on my home page along with the rest ‘standard’ posts. So, in my functions.php I added
add_filter('pre_get_posts', 'include_my_events'); function include_my_events($q) { if ( !is_admin() && is_home() ) { $post_types = array('post','viernes'); $q->set('post_type', $post_types); } return $q; }
The thing is, this last piece of code messes with the fonts I use and I don′t know why. Now the links on the sidebar, footer and even the ‘Read more’ tag appear unformatted.
I’ve already tried doing the same thing using regular ‘image’ posts instead of a custom post type, but for whatever reason, the single-image.php nor the image.php files (containing the same code I wrote earlier) seem to have any effect.
Any help is much appreciated!
- The topic ‘[Theme: Gateway] Help with custom post types’ is closed to new replies.