ThemeShaper Forums » Thematic

[closed]

Changing how post is being displayed

(7 posts)
  • Started 3 years ago by Blue_Bannana
  • Latest reply from helgatheviking
  • This topic is resolved
  1. Blue_Bannana
    Member

    Hello everyone, I'm in a bit of trouble - maybe I'm blind but I've been looking for an answer pretty much everywhere and I can't really find it. Though I'm not really a php guy, so that might be the reason. Or I'm just plain stupid. ;)

    What I'd like to do is, I want my post to display as following:
    title
    picture of post, then aligned to the right (or along picture settings set during post creation) in one line: on the left date and comments, on right facebook button, then after break excerpt and in footer read more link (not right after excerpt like in default).

    So no header because I want my date to display where post should start on the right to the picture, and moved read more.

    What I did is this:

    <?php function remove_nav_above() {
    remove_action('thematic_navigation_above', 'thematic_nav_above', 2);
    }
    add_action('init','remove_nav_above');
     ?>
     <?php function childtheme_postheader() {
        global $post;
    
        if (is_page()) { ?>
            <h1 class="entry-title"><?php the_title(); ?></h1>
        <?php } elseif (is_404()) { ?>
            <h1 class="entry-title">Oj! Nie odnaleziono! :(</h1>
        <?php } elseif (is_single()) { ?>
            <h1 class="entry-title"><?php the_title(); ?></h1>
            <div class="entry-meta">
            <span class="entry-date"><abbr class="published" title="<?php get_the_time('Y-d-m:i:sO'); ?>"><?php the_time('j F, Y') ?></abbr></span>
            </div><!-- .entry-meta -->
        <?php } else { ?>
            <h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s', 'thematic'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title() ?></a></h2>
        <?php }
    }
    add_filter ('thematic_postheader', 'childtheme_postheader');
    
    function childtheme_postfooter() {
        global $post;
    
        if (is_single()) { ?>
            <div class="entry-utility">
                <?php printf(__('<a href="%1$s" title="Permalink do %2$s" rel="bookmark">Permalink</a> do tego postu.', 'thematic'),
                    get_permalink(),
                    wp_specialchars(get_the_title(), 'double') ) ?>
    
        <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) : // Comments and trackbacks open ?>
                <?php printf(__('<a class="comment-link" href="#respond" title="Dodaj komentarz">Dodaj komentarz</a> lub pozostaw trackback: <a class="trackback-link" href="%s" title="URL Trackback do tego postu" rel="trackback">Trackback URL</a>.', 'thematic'), get_trackback_url()) ?>
        <?php elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) : // Only trackbacks open ?>
                <?php printf(__('Comments are closed, but you can leave a trackback: <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback URL</a>.', 'thematic'), get_trackback_url()) ?>
        <?php elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) : // Only comments open ?>
                <?php printf(__('Trackbacks are closed, but you can <a class="comment-link" href="#respond" title="Post a comment">post a comment</a>.', 'thematic')) ?>
        <?php elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) : // Comments and trackbacks closed ?>
                <?php _e('Both comments and trackbacks are currently closed.') ?>
        <?php endif; ?>
        <?php edit_post_link(__('Edit', 'thematic'), "\n\t\t\t\t\t<span class=\"edit-link\">", "</span>"); ?>
    
            </div><!-- .entry-utility -->
        <?php } else { ?>
            <?php if ( $post->post_type == 'post' ) { // Hide entry utility on searches ?>
                <div class="entry-utility">
                    <span class="meta-nav"><?php get_the_content(__('Leave a comment', 'thematic'), __('1 Comment', 'thematic'), __('% Comments', 'thematic')) ?></span>
                </div><!-- .entry-utility -->
            <?php } ?>
        <?php }
    }
    add_filter ('thematic_postfooter', 'childtheme_postfooter');
    ?>

    And here's my shot at changing post (but doesn't really work the way I want it to, ie. doesn't show post at all. ;)

    <?php
    function childtheme_post() {
        global $post;
    
        if (is_single()) { ?>
    
        <?php } else { ?>
            <?php if ($post->post_type == 'post') { // Hide entry meta on searches ?>
            <div class="entry-meta">
                <span class="entry-date"><abbr class="published" title="<?php get_the_time('Y-d-m:i:sO'); ?>"><?php the_time('j F, Y') ?></abbr></span>
    			<span class="meta-sep">|</span>
    			<span class="comments-link"><?php comments_popup_link(__('Leave a comment', 'thematic'), __('1 Comment', 'thematic'), __('% Comments', 'thematic')) ?></span>
                <?php edit_post_link(__('Edit', 'thematic'), "\t\t\t\t\t<span class=\"meta-sep\">| </span>", "</span>\t\t\t\t\t"); ?>
            </div><!-- .entry-meta -->
    
            <?php } ?>
        <?php }
    
    }
    add_filter ('thematic_post2', 'childtheme_post');
    ?>

    Also I've found something like that:

    <?php
    function remove_index_loop() {
      remove_action('thematic_indexloop', 'thematic_index_loop');
    }
    add_action('init', 'remove_index_loop');
    
    function snippet_index_loop() {
      global $post;
            /* Count the number of posts so we can insert a widgetized area */ $count = 1;
            while ( have_posts() ) : the_post() ?>
                <?php $counter++; $clear=''; ?>
    			<div class="column <?php if ($counter == 1) { echo 'one'; } elseif ($counter == 2) { echo 'two'; }  else { echo 'three'; $counter = 0; $clear='<div style="clear:both;height:0px;"></div>';} ?>">
    			    <div class="clear-fix">
                        <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
                            <?php thematic_postheader(); ?>
                            <div class="entry-content">halo
                                <?php the_excerpt(); ?>halo
    							<?php the_content(); ?>halo
                                <?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
                            </div>
                                <?php thematic_postfooter(); ?>
    
                        </div><!-- .post -->
                    </div><!-- .clear-fix -->
                </div><!-- .column -->
    
                        <?php comments_template();
                        if ($count==$thm_insert_position) { get_sidebar('index-insert');}
    
    		echo $clear;
            $count = $count + 1;
            endwhile;
    }
    add_action('thematic_indexloop', 'snippet_index_loop');
    ?>

    but it's not really what I'm looking for because thumbnail isn't there, and read more button vanishes too..

    So what I'm asking is: how to put date etc. divs right above post text, and how to move read more?

    Thanks for your help!

    Posted 3 years ago #
  2. hanswurst
    Member

    Uff! I think maybe a concept drawing (rudimental Paint picture) of what you want to reach would be really helpfull. Also, which CSS are you using? By what I did understand so far it's possible to do what you want, with the propper HMTL and CSS mark-up.

    Posted 3 years ago #
  3. Blue_Bannana
    Member

    Hey, sure - thanks for your reply.
    http://imageshack.us/photo/my-images/836/postxt.jpg/ - something like that.

    Posted 3 years ago #
  4. you're way off base on your filters. see the little primer i wrote on filters and hooks:

    http://forums.themeshaper.com/topic/need-help-understanding-actions-vs-filters-and-changing-post-meta-and-utility#post-22638

    and you don't need to filter the anymore anyway.... you can just define childtheme_override_single_post() (though you will probably still filter the meta and stuff)

    btw- i can't tell if you are trying to edit the single post or how the post looks on the index. if the later you won't override single_post but would use childtheme_override_index_loop

    Posted 3 years ago #
  5. Blue_Bannana
    Member

    Hello and thank you for your reply.
    Unfortunately, I'm still unable to do much.
    When using function childtheme_override_index_loop I just can't display the post at all.
    I guess what I'm really asking is - what's drawing the_content output?
    As an example I'll show you this:

    <?php
    function childtheme_override_index_loop() { ?>
    			<div class="block">
                                        <h1><?php the_title(); ?></h1>
                                        <p class="date">
                                            <?php the_date('d F Y'); ?>
    
                                            <?php the_content(); ?>
    
                                    </div>
    
    			<?php
    			}
    add_action('init','childtheme_override_index_loop');
    ?>

    Which in theory should show title, date and content. It shows title only, which is not linked or styled, also only newest one.
    What I've also tried to do is to copy all lines from content-extensions which should create content (lines 805-837) and paste into override, but then I'm still not getting anything.

    I understand how filters and hooks work (or at least I think I do) but I haven't found any hooks that could lead me to the insides of the_content() anywhere, and my question is how to modify it?

    If I want to add bacon everywhere, I simply write function (that);{ echo ('bacon');} add_filter('here','that'); and I'm done.
    But I have no clue what actually outputs the_content or thematic_content.
    Like get_permalink() etc. Doesn't it work that way? Where can I find what's actually inside the_content so I can modify it?

    Edit: today I had an idea but I just don't know how to deliver: what if I did div for picture, then add div for content in which I'd add date etc. Basic idea:

    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
                            <?php thematic_postheader(); ?>
    
    						<?php the_post_thumbnail(array(150,150), array ('class' => 'alignleft')); ?>
                            <div class="entry-content">
    							<span class="entry-date"><abbr class="published" title="<?php get_the_time('Y-d-m:i:sO'); ?>"><?php the_time('j F, Y') ?></abbr></span>
    							<?php the_excerpt(); ?>
    							<a href="<?php get_permalink(); ?>">a</a>
    							<?php wp_link_pages('before=<div class="page-link">' .__('Pages:', 'thematic') . '&after=</div>') ?>
                            </div>
                                <?php thematic_postfooter(); ?>
    
                        </div>

    But with that i can't get the permalink to link to my single. Also this is set in thematic_indexloop, and not in childtheme_override_index_loop. Also what's code to display post image instead of thumbnail? get_post_image or has_post_image doesn't seem to work. :(
    Any help on how to get this working would be greatly appreciated.

    Posted 3 years ago #
  6. Blue_Bannana
    Member

    Here's how I dealt with this if anyone is interested:

    function remove_index_loop() {
      remove_action('thematic_indexloop', 'thematic_index_loop');
    }
    add_action('init', 'remove_index_loop');
    
    function alt_index_loop() {
      global $post;
            while ( have_posts() ) : the_post() ?>
                <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
                            <?php thematic_postheader(); ?><hr />
    						<div id="thumbnail"><?php the_post_thumbnail(array(150,150), array ('class' => 'alignleft')); ?></div>
    						<div class="entry-content">
    							<span class="entry-date"><?php the_time('j F, Y') ?></span>
    							<span class="meta-sep"> | </span>
    							<?php the_excerpt(); ?>
    						<div class="footer_more"><a href="<?php the_permalink(); ?>" title="Czytaj więcej">Czytaj więcej</a></div>
                             </div>
                        </div>
    <?php
            endwhile;
    }
    add_action('thematic_indexloop', 'alt_index_loop');
    Posted 3 years ago #
  7. thanks for posting your solution. you can still use the override (versus removing and adding a function). the difference is that before you left the loop out, so you were getting stuck w/ only 1 post. in your working solution you have:

    global $post;
    while ( have_posts() ) : the_post() ?>

    glad you fixed it.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.