Announcement

Collapse
No announcement yet.

Custom Hook Boxes: Post Title

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Hook Boxes: Post Title

    I'm trying to put a post title after my header. I can do it by using Dynamik Custom Functions:
    add_action( 'genesis_after_header', 'genesis_do_post_title' );

    But I would rather like to use Dynamik Custom Hook Boxes hooked into after_header. What php code goes in the box for post title?

  • #2
    PHP Code:
    <?php genesis_do_post_title(); ?>

    Comment


    • #3
      Great - thanks JA

      I suspected it would be something simple like that.
      So now I'm guessing I can call any Genesis function - as found in the php builder actions list - in that way, and plug it into a Custom Hook Box.
      If that's the case then we're really cooking..

      Comment


      • #4
        Can I add a question here, guys, as it seems to be the right topic? I tried to move the title (in my case: page titles) and create it´s own "area" (and style it) under the header a while ago and found this:
        http://www.satoritechsolutions.com/b...genesis-theme/

        But I couldn´t work out how to add my own class to this title, for example. Also, the title displayed twice. I´d be grateful, Simon, if you could share/explain your solution here, maybe it could bring me a step further....

        Comment


        • #5
          Hi SiGa, today is my first time using hook boxes, but your requirements are very much on-topic with what I'm trying to do..

          At a glance that link you provided seems to use the more traditional Genesis method, which Dynamik makes easier with Hook Boxes.
          Looking at Eric's screencast, at about 1:40 he says you don't need a class field in Hook Boxes because you can simply add them in the content as HTML:
          http://dynamiksupport.cobaltapps.com...tom-hook-boxes
          - that makes sense, not that I've tried it yet..

          As for the title displaying twice you would need to create a remove action for post titles (posts and pages being the same thing at that level).
          HTML5: remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
          Pre-HTML5: remove_action( 'genesis_post_title', 'genesis_do_post_title' );

          I'm not sure if removes can be done in Hook Boxes, or only via Functions, in which case I wouldn't know how to make them conditional to pages only.
          This is something I need to find out today..
          Taking WordPress Hooks To A Whole New Level! The Custom Hook Box option makes it not only super easy to create an u...
          Last edited by simbasounds; 10-15-2013, 09:42 AM.

          Comment


          • #6
            Like you, I´m only now diving into hooks, conditionals, labels and things like these.
            Nonetheless, your hints indeed brought me a step further - trying out your unregister code in functions (I should have thought of this) and a hookbox with conditionals, I got rid of the title displaying twice and I have a class I can address now.
            If that isn´t progress!

            The downside: The function will remove ALL titles everywhere which means on the Blog page, the post titles (and with them the link to post single) are gone, too. And here is where the challenge starts...
            I guess this would need some function finegraining to add them back in like here: http://transmitstudio.com/wordpress/...nd-in-genesis/
            Unfortunately this is where my knowledge ends for now. :P

            Comment


            • #7
              Same here I would prefer to do a conditional remove_action in Custom Hook Boxes.. anyone?

              Failing that, there seem to be three possible methods:
              1. A Custom Functions method, like you suggest, SiGa

              2. Hiding titles via CSS, using body classes as conditionals eg.
              .page .content h1.entry-title {display: none;}

              3. Building the page from the bottom up as a new template - as per Eric's latest screencast: http://dynamiksupport.cobaltapps.com...id-backgrounds

              - probably not ideal in my case, since I'm re-doing an existing site - it already has a lot of content:
              Existing site: http://alltheevents.co.za/
              My new dev: http://themeselector.com/alltheevents/

              - so manually re-assigning the new template to all blog posts, for example, would be impractical, unless there's a quick method? - and assuming this method is indeed a good idea.
              Last edited by simbasounds; 10-15-2013, 11:23 AM.

              Comment


              • #8
                Oh.. it works! SiGa, here's the solution:

                Perform a conditional remove_action in Custom Hook Boxes:
                (specifically: removing titles from pages only)

                1. Create a Custom Conditional for is_page
                2. Create a new Custom Hook Box called "remove_page_title" or something..
                3. Assign it to the wp_head hook
                4. Set the conditional to is_page
                5. Generate the remove_action code in the php builder and paste it in
                <?php remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); ?>

                Voila!
                Last edited by simbasounds; 10-15-2013, 11:57 AM.

                Comment


                • #9
                  Thought I'd add something else which ties in well with this functionality: Featured Images

                  Since Genesis doesn't have a featured image function you can create one by adding this to Dynamik Custom Functions:

                  function featured_image() {
                  if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
                  printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
                  }}

                  Then you can simply add:
                  <?php featured_image(); ?>

                  to your Custom Hook Boxes in the hook location you want it to appear, with conditionals if needed..

                  Comment


                  • #10
                    Hm, maybe I got you wrong but I still got the same result here - the title is moved, but the problem that post titles are removed on the Blog page also still persists.
                    I deleted the remove code from functions and put it into the new hook box like suggested in #8. Additionally I got the hook box to put the title back in where I want it. Works fine but addresses all titles - or did you get another result?

                    Oh wait, I just had another idea and tried that: In Dynamik Settings - General Settings, I checked "Remove All Page Titles". Then I deactivated the remove_title hookbox. That gave me back my post titles and the page titles are displayed where I hooked them!
                    Didn´t have the chance to test if this has any downsides yet but for the moment, it seems like the solution I searched for!
                    Many thanks, Simon, for the insight - I actually didn´t know I could do the remove actions in hookboxes, too - that adds some more flexibility indeed! Always glad to learn something new...

                    Comment


                    • #11
                      Worked fine on this side: only removes page titles, not posts, or blog page titles. Are you sure you set the conditional to "is_page"?
                      Glad you found another solution another good idea for the knowledge base..

                      Comment


                      • #12
                        I just visited the deactivated hookbox and double-checked - yes, the conditional was set, but I have a Blog page with template "Blog" to display my posts, and a static homepage, so maybe this makes a difference to your setup? Not sure...

                        Comment


                        • SiGa
                          SiGa commented
                          Editing a comment
                          Oh damn, I jumped to WP settings - Reading right after writing this and the static homepage was chosen but not the Blog page... *head-on-desk* LOL
                          Activated the hook box - works perfectly! You made my day, thanks, Simon!

                      • #13
                        ah.. great.. as far as learning goes it's been an epic day

                        Comment


                        • SiGa
                          SiGa commented
                          Editing a comment
                          Very true!

                      • #14
                        I am trying to remove post date and author name (October 21, 2013 by admin)

                        I have created custom template in Dynamik Custom Functions with following code:

                        <?php
                        get_header();
                        genesis();
                        ?>

                        <?php
                        add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' );
                        ?>



                        <?php get_footer();



                        I have created custom post type with wp types plugin.
                        In wp types > Views > Content templates > Single beach content template
                        i have the following code:

                        <div class="one-half first">
                        [wpv-post-featured-image size="large"]
                        </div>

                        <div class="one-half">
                        [wpv-post-featured-image size="large"]
                        </div>


                        <div>
                        [wpv-post-body view_template="None"]
                        </div>

                        So now i can get my custom post content displayed using single-beach.php and content template from Views plugin.

                        When custom template single-beach.php not existed(created) the content was displayed correctly and showed only the fields as i set in wp views content template.
                        Ok but i was missing sidebar, post title. Only featured images and post body were displayed.

                        My next attempt was to create the single-beach.php custom template as desbribed above.

                        I have post title (which i shouldnt) and post date , by author

                        How can i control this? e.g how to remove post title or post date etc. ?

                        Comment


                        • #15
                          Found the solution finally. http://cobaltapps.com/genesis-custom-php-builder/
                          I create a conditional and then in hook boxes filled the required php code (code build with DWB PHP builder)
                          Awesome tool!

                          Comment

                          Working...
                          X