• Resolved klewis

    (@blackawxs)


    Can anyone on this theme team, provide an online guide as to how we can build a custom block that renders in WordPress logic, for these new templates within the Twenty Twenty Two theme?

    I see that when we edit posts, we have the ability to add new or edit templates. That is fine, but I am ready to extend from this point and learn how to incorporate loops, hooks, filters and various do actions into these templates if possible.

    Any source of learning you have “for this specific theme” would be very much appreciated!

    Many thanks!

    • This topic was modified 2 years, 9 months ago by klewis.
    • This topic was modified 2 years, 9 months ago by klewis.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Desperately looking into the same thing. Closest discussion I could find so far is this github thread that is an open issue: https://github.com/WordPress/gutenberg/issues/32939

    Hi

    I don’t know if it suits your purpose,

    Template hierarchies are still alive in themes that use HTML templates, such as Twenty Twenty Two.

    When using child themes, parent theme block-templates / single.html
    If child theme / single.php exist at the same time, single.php will be applied to the template.

    This means you can use her conditional tags that we used to use.

    example child theme / single.php

    <?php
    get_header();
    
    if ( have_posts() ) {
    
    	 while( have_posts() ) {
    
    	 	the_post();
    
    	 	the_title();
    
    		the_content();
    	 }
    }
    get_footer();
    

    get_header () get_footer () is a function that calls header.php, footer.php, but since these files do not exist in the parent theme, wp-includes / theme-compat / header.php, … footer. Notice that php is called.

    I’m writing the following blog about these details

    https://www.tenman.info/wp3/emulsion/en/2022/01/27/%e3%83%81%e3%83%a3%e3%82%a4%e3%83%ab%e3%83%89%e3%83%86%e3%83%bc%e3%83%9e%e3%83%96%e3%83%ad%e3%83%83%e3%82%af%e3%83%86%e3%83%bc%e3%83%9e%e3%81%ae%ef%bc%89/

    These are by no means ideal, but I think they may be useful for those who continue to maintain the site today.

    Thank you.

    It would be easier for the team to know what feature you want to change and what is missing, if you can provide a more detailed use case.

    I know you asked for help with this specific theme, but from the description it sounds more like you want to extend the query block?

    One way to add some more dynamic content to any template, is to use block patterns, since block patterns uses PHP.

    Thread Starter klewis

    (@blackawxs)

    Thank you so much Carolina for jumping on this thread! I’m actually reading up on your theme.json course materials on the web as of now, and learning a lot! I believe that was the first thing I needed to dive into. I feel like I’m doing “ok” for now.

    Many thanks for following up!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to add logic to Post Templates’ is closed to new replies.