Forum Replies Created

Viewing 15 replies - 586 through 600 (of 681 total)
  • Took me all day, but I’ve come up with a solution for this.
    NOTE: this new solution is incompatible with the find&replace one posted above. Make sure you delete the replacement rule from RTFR plugin first.
    Also, you need to delete class-header-nav_walker.php from child theme and only leave the original in parent theme.

    My advice is to eliminate all other styling you’ve done for menu and reaply it (if necessary) after you activate the the filter function.

    While you’re at it, you might also want to replace the white text-shadow, looking out of place especially on hover. Completely optional, of course. Besides a.site-title I have added a few more selectors to the rule for the other header elements that have the white text-shadow problem. I hope I haven’t missed anything:

    a.site-title,
    .navbar .nav > li > a,
    .navbar-wrapper .navbar h2,
    h2.site-description {
    text-shadow: 1px 2px 3px rgba(0,0,0,.35);
    }

    P.S.: put it as a new CSS rule, don’t mix it with the previous one.

    a.site-title or .tc-header .brand a will do it:

    a.site-title {
      color: #EEDCC3;
    }

    @electricfeet: this is the beauty of WP and its’ child themes system.

    functions.php of the child theme is an addition to functions.php of the parent theme.

    The really cool part is that the child version is read just before the parent version. Why is it so cool? Because it gives theme developers the ability to make their functions pluggable. To wrap them in a

    if( ! function_exists('name_of_function') ) {
      function name_of_function( $params ) {
      // do some stuff with the $params  }
    }

    This gives child theme ‘devs’ the ability to completely replace functions declared in the parent theme. By the time WP finds them in parent functions.php they exist and get skipped (because of the function_exists() condition).

    However, nikeo used another great feature of WP: apply_filters().
    This gives us the ability to declare (in functions.php of the child theme) a new function that filters the output of an existing one (so we’re not replacing the function, just alter/replace its output):

    add_filter('old_function', 'new_function');

    Now all you need to do is create the new_function() (also in your child theme’s functions.php). Without any parameter, it simply replaces the output of old_function with its own output:

    function new_function() {
    $new_output = 'New output';
    echo $new_output;
    }

    If you want the new_function to alter the content of old_function, declare it with one parameter, and that param will contain the output of the old_function:

    function new_function($output) {
    /* $output now holds the output of the old_function and you can alter
     * it as you want, using preg_replace or adding to it or hacking it
     * anyway you like. In this example I'm just adding $new_output after
     * the original output:
     */
    $new_output = '<div>This text has been added using apply_filters on old_function(), never touching parent theme core files! Cool, huh?</div>';
    echo $output.$new_output;
    /* Please note that some functions need the output echoed and others
     * want it returned, so you'll need to replace echo with return in
     * some cases. Just look at old_function() and you'll know.
     */
    }

    Hope this sheds some light on why WP’s slogan is “Code is poetry”. 🙂

    And why nikeo did such a great job with the dev tools. If you look in the tootips, you will see on last line:
    filterable with: add_filter(‘name_of_original_function’, ‘generic_name_for_new_function’); so you can add in your child theme’s functions.php

    add_filter('name_of_original_function', 'coolest_function_name_evah')
    function coolest_function_name_evah($original_output) {
    // filter and return/echo the output to your liking
    }

    And you’re done without having to worry about Customizr updates overriding your filter.

    Thread Starter acub

    (@acub)

    I would be honored, Nicolas.

    @ithril:
    In your solution, customizr/parts/class-footer-footer_main.php gets overridden by [child-theme-folder]/parts/class-footer-footer_main.php.
    This means that if in some theme update the author decides to improve or change the footer social links or the back-to-top link in the footer, anyone using my solution will benefit from the upgrade, while the ones using your solution will not, because the whole file from parent theme gets ignored. Also, my solution replaces a function, not a file, and will continue to work even if the parent function will be moved in another file or if the file structure changes and the theme expects a different output from class-footer-footer_main.php, while yours will graciously fail.

    @rdellconsulting: can you change the contents of the footer with your solution?

    @albafitness: that code should go in your functions.php file from your child theme folder, just before the ending line, which should remain intact and contain:

    ?>

    Actually, because your child theme is newly created and I assume you don’t have any other custom function added to it, just save the following code as functions.php in your child theme, replacing the old functions.php:

    <?php
    add_filter('tc_credits_display', 'my_custom_credits');
    function my_custom_credits(){
    echo '<div class="span4 credits">
        		    	<p> &middot; @copy; '.esc_attr( date( 'Y' ) ).' <a href="'.esc_url( home_url() ).'" title="'.esc_attr(get_bloginfo()).'" rel="bookmark">'.esc_attr(get_bloginfo()).'</a> &middot; {Replace this accolade with your link, Alba!} &middot; </p></div>';
    }
    // Add any future custom php functions after this line and make sure the last line of the file remains untouched!
    
    ?>

    There is one more very important instruction which I think you missed in my previous post, Alba:

    Of course, you’ll need to replace the part between the last two middots with your own stuff.

    To make it easier, this time I wrote {Replace this accolade with your link, Alba!} where your link should go.

    WordPress doesn’t have a “default author box”. Whenever you see one, it’s either a plugin, or a code written by the theme author, or a code copy/pasted from a plugin into the theme, by the theme author.

    Customizr doesn’t currently have an author-box feature, afaik.

    If you want to read someone else’s review over the best plugins for a task in WordPress,

    [your_search_engine_of_choice]/search?q=best+wordpress+[what_you_need]+plugin(s)/

    will usually find it to you…

    http://www.google.com/search?q=best+wordpress+author+box+plugins

    Alternatively, you could just search the WordPress plugin repository:

    http://wordpress.org/plugins/search.php?q=author-box

    In your functions.php (which should be empty), add this code in between the php markup delimiters:

    add_filter('tc_credits_display', 'my_custom_credits');
    function my_custom_credits(){
    echo '<div class="span4 credits">
        		    	<p> &middot; &copy; '.esc_attr( date( 'Y' ) ).' <a href="'.esc_url( home_url() ).'" title="'.esc_attr(get_bloginfo()).'" rel="bookmark">'.esc_attr(get_bloginfo()).'</a> &middot; Designed by <a href="'.TC_WEBSITE.'">Themes & Co</a> &middot;</p></div>';
    }

    Of course, you’ll need to replace the part between the last two middots with your own stuff.

    Thread Starter acub

    (@acub)

    @stickfinger: I don’t see that happening, really.

    The blog template itself doesn’t add a lot of functionality, except for people who want to have the blog list in two places on their site: the first page (through theme options) and on a separate blog page, using this template. If you don’t want the blog on first page, you can just select the blog page from theme options without a template.
    The real use of the code above is the possibility to tailor the query string to your needs and create a the custom list of posts you need, in a static page.

    The snippet I posted may seem like a lot of code, but it’s not. Besides declaring the template, I only added two lines of code to index.php:

    <?php query_posts(' some_qyuery_string '); ?>

    and

    <?php wp_reset_query(); ?>

    Looking at it now, I even think I could have done it better. I should have placed them so that sidebars get included in the custom query, not excluded. On a lot of complex CMS’s sidebars display different content depending on the page/query being displayed and my sidebars (in the example above) are told they’re on a static page, while they should be told they’re on a custom query page and display accordingly.

    What I’m saying is that Customizr doesn’t need a blog template so much, but having a guide on how to make a template for a custom list of posts may have some value in some situations. But you need to come up with the custom query string yourself to make it useful, and that cannot be added in a “future Customizr upgrade”.

    You have to Customiz’it!

    In order to keep your footer changes on theme updates you need to address the function that builds the footer, not the function’s result. Fortunately, like most Customizr functions, the credits function can be filtered (replaced).

    Add this code to your functions.php of your child theme:

    add_filter('tc_credits_display', 'my_custom_credits');
    function my_custom_credits(){ ?>
    
    <!-- Put your custom html here.
    Don't forget to uncomment it!
    If you want to mimic the style
    of the original credits, don't
    forget to add middots before
    and after and wrap it up in a
    div.span4.credits 
    
    Cheers! -->
    
    <?php }

    If this is the very first function you add to your child theme, just add

    <?php

    before and

    ?>

    below the code above and save it all as functions.php in your child theme.

    Go to Customiz’it! panel in the backend (the blue button in the bar). Open the Custom CSS tab and input:

    .archive.category .archive-header .format-icon:before { content: ""; }

    If you want to remove all the icons from the theme, not just the one for .archive.category, input this code:

    #main-wrapper .format-icon:before { content: ""; }

    If you want to change their color, change the theme color from the Customiz’it! dashboard section or add this code in the Custom CSS tab:

    #main-wrapper .format-icon:before { color: #ddd; }

    #ddd is just a random custom color here, you can change it to any other valid html color code.

    And, by the way, if you have more questions that are not related to the original request, you should open new threads, so they get properly indexed and other users benefit from the answers.

    functions.php of the child theme does not render functions.php of the parent inactive, it just comes as an addition to the parent’s version. They are both active at the same time and that means you can’t have duplicate code in them or you get severe php errors.
    This is all well described and documented in Child themes documentation.

    Therefore, the functions.php of a child theme should look like this when the theme has just been created:

    <?php
    
    ?>

    In your case, since you don’t have any previously defined function in your child theme, it should look like this (I added nikeo’s code from above).

    <?php
    add_filter( 'tc_category_header', 'my_category_header' );
    function my_category_header($html) {
    	?>
    	 <header class="archive-header">
            <h1 class="format-icon">
            	<span><?php echo single_cat_title( '' , false )?></span>
            </h1>
    
            <?php if ( category_description() ) : // Show an optional category description ?>
              <div class="archive-meta"><?php echo category_description(); ?></div>
            <?php endif; ?>
          </header><!-- .archive-header -->
         <?php
    }
    // In the future, add new functions right after this line, but before the last one, that closes the php markup
    
    ?>

    Should work like a charm.

    Thread Starter acub

    (@acub)

    I have made a new topic on this subject, as a how to. The code is simplified a bit and I also explain there how to make templates for custom lists of posts for Customizr.

    I’ll mark this one as resolved as it contains code and solutions that are no more working in the current theme version.

Viewing 15 replies - 586 through 600 (of 681 total)