Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Montezuma Theme (http://forum.bytesforall.com/forumdisplay.php?f=53)
-   -   MODIFY bfa_loop() (http://forum.bytesforall.com/showthread.php?t=23430)

robysan83 Mar 3, 2016 08:51 AM

MODIFY bfa_loop()
 
Hi,
I have a question.
If I should change the bfa_loop( ) function to show the post at the start page, with this structure:

Last Post for category one
______________________
Last Post for category two
______________________
Last Post for category three
______________________
Last Post for category four

Basically , I want to show the last article for all single category in my blog.
I saw that the bfa_loop function( ), show all article regardless of category.
Can I change the bfa_loop( ) fuction without the change is lost in case update theme?

juggledad Mar 3, 2016 07:52 PM

Any change to the themes code will be lost over an update of the theme.

robysan83 Mar 4, 2016 12:44 AM

Quote:

Originally Posted by juggledad (Post 113436)
Any change to the themes code will be lost over an update of the theme.

Yes, I imagined it was so.
But if if you employ the child theme WP functionality, changing montezuma code, you could have user to able a child theme to redefine a function in parent.
For example for bfa_loop() you should change montezumas'code with this:
Code:

if (!function_exists( 'bfa_loop' ) ){
  function bfa_loop() {
    ....
  }
}

Exploiting the mechanism of child theme, I can create a file in directory includes/ of my child theme to redefine bfa_loop function and include it whitout an redeclaration error.
To do this, however, we should change the montezuma's core.
I hope you have understood me.

robysan83 Mar 4, 2016 09:04 AM

I solve it whitout child theme

juggledad Mar 4, 2016 03:00 PM

Care to explain your solution for others?

robysan83 Mar 5, 2016 02:56 PM

I have create a virtual main template named home.php in Montezuma Options -> Main Templates, with this code:
Code:

<!--<div id="container">-->

<?php get_header(); ?>

<div id="main" class="row">
       
        <div id="widgetarea-one" class="col4">
                <?php dynamic_sidebar( 'Widget Area ONE' ); ?>
        </div>

        <div id="content" class="cf col8">
               
                <div class="my-category">
                              <?php bfa_custom_query( 'category_name=category_oneshowposts=1' ); ?>
                 
                        <?php bfa_loop( 'postformat' ); ?>
              </div>
              <div class="my-category">
                              <?php bfa_custom_query( 'category_name=category_two&showposts=1' ); ?>
                 
                        <?php bfa_loop( 'postformat' ); ?>
              </div>
              <div class="my-category">
                              <?php bfa_custom_query( 'category_name=category_three&showposts=1' ); ?>
                 
                        <?php bfa_loop( 'postformat' ); ?>
              </div>
              <div class="my-category">
                              <?php bfa_custom_query( 'category_name=category_four&showposts=1' ); ?>
                 
                        <?php bfa_loop( 'postformat' ); ?>
              </div
        </div>
       
        <div id="widgetarea-two" class="col4">
                <?php dynamic_sidebar( 'Widget Area TWO' ); ?>
        </div>

</div>
       
<?php get_footer(); ?>

<!--</div>-->

This code, create four section, one for each Post's category and show only last Post of each category, by executing query_post() function before loop.
After, I have create a Page named Home and I assigned the Virtual Main Template home.php created, by dropdown "Virtual Template" on the right bottom.
Finally, I assigned in WP -> Read -> Front page displayes, A static page (select below) -> Front page: Home.

juggledad Mar 5, 2016 06:21 PM

Nicely done! And thanks for sharing.


All times are GMT -6. The time now is 08:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.