• Custom CSS and Custom Actions

    by  • August 8, 2011 • Documentation • 29 Comments

    If you are familiar with PHP, you might have already taken a look under the hood of PressWork to see how things work. Hopefully it doesn’t all look like gibberish and you can pretty much understand how we decide to code it. We tried our best to comment every function so that you can easily figure out what does what. We also added two button to the toolbox so that you can display functions and hooks to see what is powering each element on a page.

    Custom Actions

    PressWork has been built so that all the customization happens through a file called actions.php. This file is located in the /admin folder of the PressWork theme directory. Take a look around to see how things works. If you feel like you want to start modifying a few things, whatever you do, DO NOT MODIFY THE CORE THEME FILES.

    There are two ways that you can easily modify the theme without messing with the core. I had previously discussed creating a child theme so you can read about that HERE.

    The other way is to create a file called custom-actions.php and upload it to your site’s /uploads directory. PressWork will automatically look for that file and load it in the appropriate place.

    With that file created, you can start to use some of PressWork’s action hooks to customize things.

    Custom Actions Examples

    NOTE: Since this is a PHP file, you need to make sure that you open the file with a PHP tag:

    <?php
    //start your custom actions after this line

    Removing the featured post section at the top of the index page:

    remove_action('pw_index_sticky_post_middle', 'pw_posts_featured');
    remove_action('pw_index_featured_post_middle', 'pw_posts_featured');

    Removing the author box from single post pages:

    remove_action('pw_single_bottom', 'pw_authorbox');

    Customizing the 404 page:

    remove_action('pw_404_middle', 'pw_404');
     
    function custom_404() {
    	echo pw_function_handle(__FUNCTION__); // displays the function name when functions are turned on
    	?>
    	<div id="post-0" class="post error404 not-found">
        	<header>
        	   	<h1 class="posttitle">My Custom 404 Page</h1>
            </header>
            <div class="entry">
                <p>You've hit my custom 404 page. There is nothing here so head back to the <a href="<?php echo home_url("/"); ?>">home page</a>.</p>
            </div>
        </div>
    	<?php
    }
    add_action('pw_404_middle', 'custom_404');

    Custom CSS

    PressWork has many theme options that allow you to customize how your site is styled. There is no need for CSS when you can choose colors and fonts using the toolbox. But what if you wanted to really delve into some custom CSS. Once again, you can look into creating a child theme, or you can create a file called custom.css and upload it to your site’s /uploads directory.

    PressWork will automatically enqueue your custom.css stylesheet and add it to the head tag. If you are familiar with CSS you can now start to customize your site’s styles without having to worry that they might get overwritten when the next update of PressWork is released.

    If you are new to CSS, there are some great tutorials available online. Here are some resources:

    http://www.w3schools.com/css/
    http://bavotasan.com
    http://www.csstutorial.net/

    I also suggest installing a tool for Firefox called Firebug (http://getfirebug.com/). This is a must have tool for everyone involved in any level of web development.

    About

    Senior Developer & Co-Founder of PressWork.

    http://bavotasan.com

    29 Responses to Custom CSS and Custom Actions

    1. Pingback: xhtml css templates – Custom CSS and Custom Actions | PressWork | XHTML CSS - Style sheet and html programming tutorial and guides

    2. NickBencino
      August 10, 2011 at 2:12 am

      remove_action is not working in the functions.php I am using in the child theme folder, nor is is working in the custom_functions. Oddly if I do add_action and ad an echo it works perfectly fine….

      If i add the remove action to the default themes function.php (presswork/function.php) it works

    3. bavotasan
      August 10, 2011 at 10:05 am

      @NickBencino The actions are suppose to go in either the custom-actions.php file in your /uploads directory OR in a file called actions.php in your child theme. They will not work in the child theme’s functions.php file because that file loads before any other file in the parent theme. So the actions you are trying to remove have not been initiated just yet.

    4. NickBencino
      August 10, 2011 at 10:29 am

      Of course, I am so used to working with Thesis theme I did not consider the obvious! Thanks for pointing that one out to me! @bavotasan

    5. aharshbarger
      August 12, 2011 at 12:34 pm

      I like what I see with Presswork. I am fairly new with WordPress, so please excuse me if my question doesn’t make sense. But, what is the reason for putting the custom actions, etc in the /uploads folder vs in the child theme folder? Doesn’t by putting these custom files in the upload folder cause problems if you have a couple different versions (children) of the PressWork parent. Sorry, I’m just trying to understand the benefit or pros/cons of using one over the other.

    6. NickBencino
      August 13, 2011 at 3:45 am

      Removing the featured posts also removes the two latests posts from the home page. So they do not simply become standard posts….

      Is there a way to fix this? Thanks!

    7. digibomb
      August 18, 2011 at 12:00 pm

      Take a look at the support forum, this question has been answered there. http://support.presswork.me @NickBencino

    8. digibomb
      August 18, 2011 at 12:02 pm

      Yes, if you have more than one actions it can conflict, but why would you? The reason for adding to the uploads directory is so that nothing is lost if you update PressWork via the WordPress Dashboard. @aharshbarger

    9. digibomb
      August 18, 2011 at 12:02 pm

      Yes, if you have more than one actions it can conflict, but why would you? The reason for adding to the uploads directory is so that nothing is lost if you update PressWork via the WordPress Dashboard. @aharshbarger

    10. aharshbarger
      August 18, 2011 at 12:53 pm

      Thanks for your reply. I understand the need for not changing the actual presswork theme directly. But my confusion is what the pros/cons would be putting the changes in the /uploads directory versus just creating a child-theme for all the changes. Does one offer more choices or flexibility than the other? @digibomb

    11. Victor93
      August 21, 2011 at 10:07 pm

      Hi, I’ve read this section but I’m not clear–how do you modify the theme to make the featured posts a full/complete post (not requiring the ‘read more’ link see the rest of the post? I think that’s what many people will want–for their readers to see the latest posts in full, then to leverage the magazine style for older posts.

    12. digibomb
      August 22, 2011 at 10:18 am

      You can do this by creating custom action for post rendering, and choose the_content() instead of the_excerpt. If you require more help please ask the question on our support forum http://support.presswork.me @Victor93

    13. digibomb
      August 22, 2011 at 10:18 am

      You can do this by creating custom action for post rendering, and choose the_content() instead of the_excerpt. If you require more help please ask the question on our support forum http://support.presswork.me @Victor93

    14. digibomb
      August 22, 2011 at 10:18 am

      You can do this by creating custom action for post rendering, and choose the_content() instead of the_excerpt. If you require more help please ask the question on our support forum http://support.presswork.me @Victor93

    15. digibomb
      August 22, 2011 at 10:18 am

      You can do this by creating custom action for post rendering, and choose the_content() instead of the_excerpt. If you require more help please ask the question on our support forum http://support.presswork.me @Victor93

    16. digibomb
      August 22, 2011 at 10:18 am

      You can do this by creating custom action for post rendering, and choose the_content() instead of the_excerpt. If you require more help please ask the question on our support forum http://support.presswork.me @Victor93

    17. Pingback: Custom PressWork mit Version 1.0.3 » WordPress, Theme, Presswork, Custom Actions, Blogdesign » Spielwiese

    18. pauldenhertog
      September 15, 2011 at 4:05 am

      I’m confused. I’ve made a child theme so that my customisations won’t be lost in case of an upgrade, but don’t like the idea of having my theme scattered all over my ftpfolder (uploads and child theme folder).

      Is there a way I can put these actions in my childs’ functions.php or another way to at least keep all the files somewhere under the presswork-child/ folder?

      Many many thanks for developing this beautiful framework, you guys rock!

    19. bavotasan
      September 15, 2011 at 9:11 am

      This is an alternative to making a child theme. If all you want to do is add/remove some actions or add some custom css, you can use this technique. If you plan on making more modifications then you should create a child theme. Adding an actions.php file to your child theme would be the same as adding a custom-actions.php file to your uploads folder.

    20. pauldenhertog
      September 15, 2011 at 9:13 am

      excellent! thanks-a-million bavotasan!

    21. pauldenhertog
      September 15, 2011 at 9:13 am

      @bavotasan Excellent! thanks-a-million bavotasan!

    22. seotut
      September 15, 2011 at 12:13 pm

      Hi guys, i have a question. I am newbie here so bare with me. I need to upload the presswork part in theme folder right? What if i allready have a great theme, can i easily change the theme with presswork or do i need to start with the presswork theme and start from there.

      please let me know

      thank you

    23. pauldenhertog
      September 15, 2011 at 12:29 pm

      @seotut I am rebuilding all my themes (6 sites) with the presswork-framework. It’s a rock-solid codebase to work with, regularly updated (unlike sandbox) and a true joy to work with (so far) ;) So yes, you can work with Presswork and using a child theme and some css fiddling you can most certainly rebuild pretty much any theme you like!

    24. seotut
      September 15, 2011 at 12:53 pm

      Great to hear presswork also works with existing themes. Even a newbie like me can edit stuff on theme? Any tutorials out there that may help?Also is there a drag drop option to make it easier editing?So i have to put the presswork folder in the themes folder right?Will start right away. thanks paul

    25. pauldenhertog
      September 15, 2011 at 12:57 pm

      @seotut it doesn’t exactly work with presswork, but you can use presswork to build your own unique version which looks similar. Just give it a try, it’s easy to switch back to your old theme if you don’t like what you end up with….have a read overhere http://codex.wordpress.org/Using_Themes

    26. November 8, 2011 at 6:47 pm

      Halp! :) First, you have an excellent theme!

      On “introducere” page the distance between H1 and H2 is very huge!… also, in the middle of the page the other H3 (with red color) has a very big margin… i tried adding margin: 0px 0px 0px 0x 0x; at each H1 – H3 but nothing happened….

      Then at a (link) text decoration I put ‘underline’ and font-weight:bold but still, nothing happened… where can i change this? Sorry for being a newbie in css! I hope you’ll help me & Thanks in advance!

    27. Pingback: Separating Presswork Theme Customizations | David Whelan: Explorations with Information and Technology

    28. RJ
      February 16, 2012 at 11:19 pm

      Hey, really dumb question. I want nothing more in the world right now than to remove the author box on single posts. I have made a custom-actions.php file but cannot figure out where/how to upload it. Just uploading it like a regular file through the wordpress dashboard gives me an error message that files of this type are not allowed for security reasons. Where do I need to put this thing?

      I like Presswork a lot, but I hate, hate, hate the author box feature. There should be a simpler way to turn it off, or at the very least, change its size and color, for users that aren’t good with CSS.

    29. Pingback: Make All Post Look Like the Featured Post | PressWork

    Leave a Reply

    Your email address will not be published. Required fields are marked *