Site logo

[Support request] Front page category sections are not pulling posts

Home Forums Support [Support request] Front page category sections are not pulling posts

Home Forums Support Front page category sections are not pulling posts

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

    Good evening!

    I have just started a new blog – apartmentdiy.com – and I am now working on the home page.

    However, on the front page using the ‘Read’ template from the GeneratePress Library, each category section does not show the newest post from that category. It looks like a Query Loop is set to pull in the data, but when I go to the ‘Taxonomies’ and ‘Select Terms’ options, there is nothing to choose.

    This also occurs on the ‘Featured Article’ tag.

    Please advise.

    Thanks in advance!

    Jason

    #2519626
    Fernando
    Customer Support

    Hi Jason,

    Can you try deleting the Query Loop Parameters and adding new ones?

    Let us know how it goes.

    #2520191
    Jason

    Hi Fernando,

    Thanks for the quick response, and it looks like that is all that was needed to get those Query Loops working!

    The one remaining issue is that in the ‘Latest Articles’ section, the parent category and child categories are showing. Is there a way to get this to only show the either the parent or the child category?

    Thanks again!

    Jason

    #2520421
    Ying
    Staff
    Customer Support

    Hi Jason,

    There should be an option to include or exclude the child category:
    https://www.screencast.com/t/pbVefVnYLnO

    #2520460
    Jason

    Hi Ying,

    I do see ‘Include child terms’ on certain Query Loops on the front page. However, that doesn’t seem to impact the visible categories.

    There is a ‘List of Terms’ Headline on the ‘Latest Articles’ section, and as of now, this is pulling all categories, whether it is a parent or child. I believe this is what would need to be adjusted, and I’ve taken a few screenshots in the link below.

    https://docs.google.com/document/d/1Q93cc3NjCAFqfQUW96DwPBWz2ViOC9ZC/edit?usp=sharing&ouid=107911175805190873970&rtpof=true&sd=true

    Thanks again!

    Jason

    #2520611
    Ying
    Staff
    Customer Support

    I see, you mean the list of terms.

    We don’t have such an option built in for the list of terms, but you can try the below method:

    1. Add an additional CSS class to the headline block which represents the list of terms, eg.custom-category-list.
    https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/

    2. Add this PHP snippet, this will return the parent category if there’s any, if there’s none, then return the child categories.

    add_filter( 'render_block', function( $block_content, $block ) {
        $categories = get_the_category();
        $parent_categories = array();
        foreach ($categories as $category) {
        if ($category->category_parent) {
          $parent_categories[] = $category;
        }
      }
        if ( ! empty( $block['attrs']['className'] ) && 'custom-category-list' === $block['attrs']['className']  && (!empty($parent_categories) )) {
        foreach ($parent_categories as $parent_category) {
    		
         $block_content = '<p class="parent-categories"><span><a href="' . get_category_link($parent_category->term_id) . '">' . $parent_category->slug . '</a></span></p>';   
      }
      }
    
      return $block_content;
    }, 10, 2 );

    Adding PHP: https://docs.generatepress.com/article/adding-php/

    Let me know if this works.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.