Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1342467

    We recently installed the Enfold theme and would like to use a custom layout for blog pages.

    So we followed the steps described in How to create a custom blog page: create a page, activate “Advanced Layout Editor”, drop in the “Blog Posts” element, save page. Go to Enfold options, Blog Layout, choose “Use the advanced layout editor to build your own blog layout …” in the “Blog Layout” select. Go to Enfold options, Theme Options, choose the page we just created in the “And where do you want to display the Blog?” select.

    This new page now shows the posts in the desired layout. However we would also like to show the archive pages (for post categories) in this layout.

    Example: we have some posts that have a category called “Aktuell”. So WordPress shows this link inside the post header: /category/aktuell/. When following this link, we see a list of posts, but these posts are not in the desired layout. I’m not sure which layout is used here, as I cannot find a setting for this.

    We tried the steps described in Change archive (category/tag) blog style: modified the functions.php and added the code shown in the link. This way we can choose from the predefined blog layouts like single-small etc. Is there a way to use our custom layout here? We tried using $layout = 'custom', but this did not work.

    Any help on how to use our custom layout for archive (category) pages would be greatly appreciated.

    #1342468

    Hey mistolt1997,
    Thank you for your question, unfortunately, you can not create a custom layout to use instead of to defined options:
    multi-big
    single-small
    single-big
    blog-grid
    bloglist-simple
    bloglist-compact
    bloglist-excerpt

    for example this sets the ‘blog-grid’ layout

    
    add_filter('avf_blog_style','avia_change_category_blog_layout', 10, 2); 
    function avia_change_category_blog_layout($layout, $context){
    if($context == 'archive') $layout = 'blog-grid';
    return $layout;
    }

    The ‘custom’ option redirects to the blog page to the one you set in the theme options, but this is not used for category pages.
    I imagine that you could create a specific “category” page using the blog element set to show only one category, and then redirect to it, but it might be a lot of work if you have a lot of categories.

    There might be another solution for you depending on what you want to be customized, for example perhaps the ‘blog-grid’ layout will work for you but you also want a specific special heading and text block above the category grid, you could add this as a shortcode in the category description, this example was for a product category, but the same can be used for a post category if you add this code to allow shortcodes in the post category description:
    add_filter( 'term_description', 'do_shortcode' );

    I hope this helps explain and gives you some ideas to achieve what you want.

    Best regards,
    Mike

    #1343341

    Hello Mike,

    thanks for your answer and the provided tips and links, we will look into them and see how we can customize the category pages.

    Basically what we would like to achieve is a layout that shows the post preview pic (like the single-small layout), but only an excerpt of the post text (like in the bloglist-excerpt layout). Maybe we can install a plugin that renders the excerpt in the single-small layout.

    #1343345

    Hi,
    Thanks for the feedback, you can set the single-small for your category pages with this function

    
    add_filter('avf_blog_style','avia_change_category_blog_layout', 10, 2); 
    function avia_change_category_blog_layout($layout, $context){
    if($context == 'archive') $layout = 'single-small';
    return $layout;
    }

    and change it to show excerpts with this function

    function change_blog_archive_style() {	
    	global $avia_config;
    	if(!is_single()){ $avia_config['blog_content'] = "excerpt_read_more"; }
    }
    add_action('get_header', 'change_blog_archive_style');

    the results
    2022-03-06_001.jpg

    Best regards,
    Mike

    #1343348

    Hello Mike,

    thanks, this works great and is exactly what we need. Awesome!

    Kind regards,
    Martin

    #1343374

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Use custom blog layout for archive (category) pages’ is closed to new replies.