ThemeShaper Forums » Thematic

[closed]

Move "page_title" below "navigation_above"

(8 posts)
  • Started 3 years ago by 11thinking
  • Latest reply from 11thinking
  • This topic is resolved
  1. 11thinking
    Member

    I am developing my first child theme for Thematic, so I'm very newbie. I'm able to find all answers on my questions by searching here and on internet, however I couldn't find an answer on this. But if it has been asked before, then I am very sorry for wasting your time.

    As the title of this topic says, I want to move the thematic_page_title below thematic_navigation_above everywhere they appear together (archive page, author page, category page, search result page, tag page).
    I think that I've to remove the page_title first and then add it below navigation_above again? The following will remove the page_title, but I don't know what's the next step.

    function remove_page_title(){
        $content = '';
        return $content;
    }
    add_filter('thematic_page_title', 'remove_page_title');

    The reason why I want it is because I've hooked breadcrumbs into navigation_above, and I want it to appear at the top of each page. It looks perfect in single posts and pages as they have nothing above navigation_above (no page_title).

    Thank you for reading, I'm looking forward to your replies!

    Posted 3 years ago #
  2. 11thinking
    Member

    And I also want to move #index-top (get_sidebar('index-top')) above #nav-above (thematic_navigation_above) as well, I think that goes exactly the same way as moving thematic_page_title below thematic_navigation_above.

    I hope that someone can at least give me a hint. Thanks!

    Posted 3 years ago #
  3. reagrding your first query. i did try last night and couldn't get anything to work. rather stumped.

    i did hack a work around together, its not pretty.
    using latest revision...
    i took your first step

    function remove_page_title(){
        $content = '';
        return $content;
    }
    add_filter('thematic_page_title', 'remove_page_title');

    then... added to the nav-above...

    function childtheme_override_nav_above(){
    
    		if (is_single()) { ?>
    
    				<div id="nav-above" class="navigation">
    					<div class="nav-previous"><?php thematic_previous_post_link() ?></div>
    					<div class="nav-next"><?php thematic_next_post_link() ?></div>
    				</div>
    
    <?php
    		} else { ?>
    
    				<div id="nav-above" class="navigation">
                   		<?php if(function_exists('wp_pagenavi')) { ?>
                    	<?php wp_pagenavi(); ?>
    					<?php } else { ?>
    					<div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&laquo;</span> Older posts', 'thematic')) ?></div>
    					<div class="nav-next"><?php previous_posts_link(__('Newer posts <span class="meta-nav">&raquo;</span>', 'thematic')) ?></div>
    					<?php } ?>
                        				</div>
                         <?php if (is_category()) {  ?>
                        <div class="page-title">Archived in: <?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?></div>
    					<?php } ?>			
    
    <?php
    }
    
    } // end nav_above

    this placed a 'current category' in the existing div class 'page-title' (that has been filtered out).

    the conditional tag in the above code

    <?php if (is_category()) {  ?>

    is telling to add to category only, so you could further add to this.

    as for css, i commented out the following so our new page-title would show on the first page of category view

    /*.paged #nav-above {
        display:block;
        padding:0 0 44px 0;
    }

    and changed #nav-above to display:block from display:none

    #nav-above {
        display:block;
        padding:0 0 44px 0;
    }

    i said it was messy. isn't ideal. if anyone can nail the function to move page title below nav above, would be great.

    Posted 3 years ago #
  4. you dont need the css, thats just to force nav at top to show from beginning

    Posted 3 years ago #
  5. 11thinking
    Member

    I return here after 8 months. The solution Jonny provided is not really what I want.

    The reason why I want to move the thematic_navigation_above above thematic_page_title is because I've replaced thematic_navigation_above with a breadcrumb function (using childtheme_override_nav_above). Except for the archive pages, thematic_navigation_above shows on top of the content.

    Today I was testing using trial and error until I finally found the solution, which is much more compact and simple than I thought. I would love to share with everyone who stumble upon this post.

    Step 1) Firstly, we remove the thematic_navigation_above (everywhere).

    function remove_navigation_above() {
      remove_action('thematic_navigation_above','thematic_nav_above',2);
    }
    add_action('wp','remove_navigation_above');

    Step 2) Then we add it again to the pages you want. In my case it is the single post, page, 404 error pages, except for attachment page.

    function add_navigation_above() {
      if ((is_page() || is_single() || is_404()) && !is_attachment()) {
        childtheme_override_nav_above();
      }
    }
    add_action('thematic_abovepost','add_navigation_above');

    Step 3) Lastly we add the page title again to the archive pages, but below the page title.

    function nav_above_pagetitle($content) {
      $navabove = childtheme_override_nav_above();
      return ($navabove . $content);
    }
    add_filter('thematic_page_title','nav_above_pagetitle');

    Done! :)

    Posted 2 years ago #
  6. 11thinking
    Member

    For Step 2): If you want to add the nav_above back to all pages, you can use the following code instead.

    function add_navigation_above() {
      if (!is_archive() && !is_attachment() && !is_search()) {
        childtheme_override_nav_above();
      }
    }
    add_action('thematic_abovepost','add_navigation_above');

    This is because the archive pages (Category, Tag, Author or a Date), the attachment and search pages have a page title.

    Posted 2 years ago #
  7. 11thinking
    Member

    And for the people who are interested (you can of course overwrite the navigation with something else!), here's the breadcrumb function which I use to override thematic_navigation_above:

    function childtheme_override_nav_above() {
      global $post;
      echo '<div class="breadcrumbs">'."\n";
      echo '<a href="';
      echo get_bloginfo('url').'" title="'.get_bloginfo('name').'">';
      echo '<strong>Home</strong></a> &raquo; ';
      if (is_category()) {
        global $wp_query;
        $cat_obj = $wp_query->get_queried_object();
        $thisCat = $cat_obj->term_id;
        $thisCat = get_category($thisCat);
        $parentCat = get_category($thisCat->parent);
        if ($thisCat->parent != 0)
          echo(get_category_parents($parentCat,TRUE,' &raquo; '));
        single_cat_title();
      }
      elseif (is_day()) {
        echo '<a href="'.get_year_link(get_the_time('Y')).'">'.get_the_time('Y').'</a> &raquo; ';
        echo '<a href="'.get_month_link(get_the_time('Y'),get_the_time('m')).'">'.get_the_time('F').'</a> &raquo; ';
        the_time('j');
      }
      elseif (is_month()) {
        echo '<a href="'.get_year_link(get_the_time('Y')).'">'.get_the_time('Y').'</a> &raquo; ';
        the_time('F');
      }
      elseif (is_year()) { the_time('Y'); }
      elseif (is_single() && !is_attachment()) {
        $cat = get_the_category();
        $cat = $cat[0];
        echo get_category_parents($cat,TRUE,' &raquo; ') . get_the_title();
      }
      elseif (is_attachment()) {
        $parent = get_post($post->post_parent);
        $cat = get_the_category($parent->ID);
        $cat = $cat[0];
        echo get_category_parents($cat,TRUE,' &raquo; ');
        echo '<a href="'.get_permalink($parent).'">'.$parent->post_title.'</a> &raquo; ' . get_the_title();
      }
      elseif (is_page() && !$post->post_parent) { the_title(); }
      elseif (is_page() && $post->post_parent) {
        $parent_id  = $post->post_parent;
        $breadcrumbs = array();
        while ($parent_id) {
          $page = get_page($parent_id);
          $breadcrumbs[] = '<a href="'.get_permalink($page->ID).'">'.get_the_title($page->ID).'</a>';
          $parent_id  = $page->post_parent;
        }
        $breadcrumbs = array_reverse($breadcrumbs);
        foreach ($breadcrumbs as $crumb) echo $crumb .' &raquo; ';
        the_title();
      }
      elseif (is_search()) {
        echo 'Search Results for '. get_search_query();
      }
      elseif (is_tag()) { echo single_tag_title('', false); }
      elseif (is_author()) { global $author; echo get_userdata($author)->display_name; }
      elseif (is_404()) { echo 'Error 404'; }
      if (get_query_var('paged')) {
        if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
        echo ' (';
        echo __('Page') . ' ' . get_query_var('paged');
        if (is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author())
        echo ')';
      }
      echo '</div>';
    }
    Posted 2 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.