• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

What is the best way to create a custom blog template ?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › What is the best way to create a custom blog template ?

This topic is: not resolved

Tagged: custom blog template

  • This topic has 9 replies, 2 voices, and was last updated 12 years, 9 months ago by Brad Dalton.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • September 17, 2013 at 1:17 pm #63028
    olivier.moreau
    Member

    Hello everybody,

    My site : omoro.fr (WPMU)
    Page involved : omoro.fr/expositions/
    Theme : Studiopress Agency (modified)

    I'm trying to create a page to display all posts belonging to one category (let's say ID=135).

    The simplest way is, of course, to create a link in the menu to show that category : http://omoro.fr/category/expositions/
    But I have no control of that pseudo page and I'd like to have different sidebar than the blog.

    Then I've tried with plugins ( like "List category posts" ) but I'm not at all happy with the presentation.

    Then I created a custom template with PHP code following WP Codex and other examples. It's much better but I have side issues with sidebars and such. It's not clean at all. That's what is running now at omoro.fr/expositions/

    From what I understand, the page_blog.php should be used as a model but it's very empty and "The blog page loop logic is located in lib/structure/loops.php". In loops.php, we find : $include = genesis_get_option( 'blog_cat' );
    Well that 'blog_cat' variable seems to be set in the theme setting and should be the simplest way to control what I want in my custom blog. I tried (very naively probably) to just set that variable in my custom template before calling Genesis loop.

    //* Template Name: Blog-expo
    $blog_cat = 135;
    genesis();

    It doesn't work at all but somehow I feel this should be best approach...

    Anybody can suggest an elegant solution ?
    Thanks in advance

    http://omoro.fr
    September 17, 2013 at 3:11 pm #63045
    Brad Dalton
    Participant

    How about Genesis Simple Sidebars plugin?


    Tutorials for StudioPress Themes.

    September 18, 2013 at 6:03 am #63159
    olivier.moreau
    Member

    Hi Brad,
    Thanks for your reply, I'm sure you have the solution !

    It is precisely because I want to use Genesis Simple Sidebars (GSS) that I have this problem... You see, I started with a standard page about the expos and I used GSS to have a specific sidebar. That was fine but it is a pain to do that page manually. It is much more efficient to just select posts with the category "expos" (ID = 135) and get that page filled up automatically. I started with a menu link to the selected posts but that doesn't create a real page where I can use GSS. Then I used a plugin, but it's not easy to respect my graphic chart with that solution.

    So I decided to create a custom made template (thanks again to show me that technique in a previous question that you answered). I got that custom template working fine but when I put in the GSS sidebar the page looks weird (as you can see at http://omoro.fr/expositions/). Thus I figured out that I should start from the standard blog template of Genesis (page_blog.php) and simply change the input. I think the control variable is 'blog_cat' but how can I do that ?

    To summarize : How can we create a custom blog template where the only change is the selection of posts ? Once this template is OK, it's easy to add GSS and all kind of other stuff in the pages using it.

    Thanks in advance for your smart advices.

    September 19, 2013 at 12:25 pm #63409
    olivier.moreau
    Member

    I found the EASY way without ANY coding at all !

    Display posts from specific category, tag on page in Genesis

    You simply create a page with the blog template and you add a custom field

    name : query_args
    value : cat=135

    You can use all kind of values. Check :

    http://codex.wordpress.org/User:JamesVL/query_posts

    September 20, 2013 at 1:10 pm #63562
    olivier.moreau
    Member

    Well I'm a bit stud born so I also find the way to create a custom blog template where the only change is the selection of posts. This is the code :`
    <?php
    //* Template Name: Blog-custom
    //* Display only posts with Category ID=135

    remove_action('genesis_loop', 'genesis_do_loop');
    add_action('genesis_loop', 'customblog_do_loop');
    function customblog_do_loop() {
    $args = array ( 'cat' => 135, 'order' => 'ASC' );
    genesis_custom_loop( $args );
    }
    genesis();
    `

    I found it after reading this excellent tutorial

    Genesis Explained Framework Actions

    It's much easier with custom field in the standard blog template but the code is more flexible.
    For instance you can add :

    remove_action( 'genesis_after_post_content', 'genesis_post_meta' );

    September 20, 2013 at 3:53 pm #63583
    Brad Dalton
    Participant

    That's good for a custom category archive. Glad you posted it. Thanks

    You can also use custom fields as well with this template.


    Tutorials for StudioPress Themes.

    September 21, 2013 at 6:41 am #63642
    olivier.moreau
    Member

    Hi Brad,
    You read my mind ! I was working on getting a custom field from my custom blog template to select the category (so I don't have to create a template doing only cat=135).

    To start simpler I was trying to replace the post metadata with a custom message stored in a field. But I just cannot get the field 'customblog_message' as a proper input for my second function. I tried with genesis_get_custom_field() but it's not OK. Any idea what's wrong ?

    <?php
    //* Template Name: Blog-custom
    //* Display only posts with Category ID=135
    
    remove_action('genesis_loop', 'genesis_do_loop');
    add_action('genesis_loop', 'customblog_do_loop');
    
    function customblog_do_loop() {
        $args = array ( 'cat' => 135, 'orderby' => 'date' );
        genesis_custom_loop( $args );
    }
    
    remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
    add_action( 'genesis_after_post_content', 'customblog_after_post' );
    function customblog_after_post() {
    	global $customblog_message;
    	?> <p class="customblog_post-meta" ><?php
    	echo 'TEST';  
    	echo genesis_get_custom_field('customblog_message');
    }
    
    genesis();
    
    September 21, 2013 at 7:08 am #63644
    olivier.moreau
    Member

    Actually the above code is working fine but the customblog_message must be in the post and not in the page made with the customblog template. That wasn't what I planned but it can also be useful...
    You can check the result at http://omoro.fr/zdoc/test-blog-custom/

    September 22, 2013 at 7:12 am #63737
    olivier.moreau
    Member

    Latest version of the custom blog template...
    Compare http://omoro.fr/zdoc/test-blog-custom/
    with the standard layout : http://omoro.fr/category/expositions/

    <?php
    //* Template Name: Blog-custom
    //* Display only posts with Category ID=135
    
    remove_action('genesis_loop', 'genesis_do_loop');
    add_action('genesis_loop', 'customblog_do_loop');
    
    function customblog_do_loop() {
        $args = array ( 'cat' => 135, 'orderby' => 'date' );
        genesis_custom_loop( $args );
    }
    
    remove_action( 'genesis_before_post_content', 'genesis_post_meta' );
    remove_action( 'genesis_after_post_content', 'genesis_post_meta' );
    add_action( 'genesis_before_post_content', 'customblog_meta' );
    function customblog_meta() {
    	global $customblog_message;
    	?> <p class="customblog_post-meta" ><?php
    	echo genesis_get_custom_field('customblog_message');
    }
    
    remove_action( 'genesis_post_content', 'genesis_do_post_content' );
    add_action( 'genesis_post_content', 'customblog_content' );
    function customblog_content() {
    		$img = genesis_get_image( array(
    			'format'  => 'html',
    			'size'    => genesis_get_option( 'image_size' ),
    			'context' => 'archive',
    			'attr'    => genesis_parse_attr( 'entry-image' ),
    		));
    		printf( '<a href="%s" title="%s">%s</a>', get_permalink(), the_title_attribute( 'echo=0' ), $img );
    	}
    
    genesis();
    
    September 22, 2013 at 10:13 am #63747
    Brad Dalton
    Participant

    Probably need a bit more space around the thumbnail images


    Tutorials for StudioPress Themes.

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble