Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   Archives Page-How can I add the date before the post title when using "postbypost"? (http://forum.bytesforall.com/showthread.php?t=2002)

fromtheranks Jun 10, 2009 02:50 PM

Archives Page-How can I add the date before the post title when using "postbypost"?
 
I'm setting up my Archives page now and, for the time being, I plan on just using: "Show Archives by Date?" = Yes, and "Archives by Date: Type" = postbypost. (I won't have hundreds of posts for the foreseeable future so, at the moment, this approach makes sense. )

But, I would like to change the following on the Archives page:

1. add the Post Date after the the bullet and before the Post Title ... without having to "go outside" to a plugin.

2. get rid of the Byline on the Archives page ... only ... it doesn't make sense to me to have it here.

Thanks in advance.

P.S. I've attached a screen shot if that will help.

fromtheranks Jun 10, 2009 10:24 PM

Okay, I think I'm beginning to get the hang of this theme :) ... I've solved one issue, the one of getting rid of the Byline on the Archive (and Sitemap) page.

I did some more research on WordPress for conditional tags and here too -- where I ran across this code example: http://forum.bytesforall.com/showpos...9&postcount=12

Using that logic, I made the following mod in my ..\themes\atahualpa333\index.php:

Code:

<?php  if ( !is_page('Archives') && !is_page('Sitemap') ) { ?> // modified 6/10/09 to drop byline from archives and sitemap pages
                        <?php bfa_post_byline(); // Post Byline: To edit the output, see functions/bfa_post_parts.php ?>
<?php } ?>

And it worked!

Note: I used the literal page titles because I suspect that when I move my dev site over onto my host's server the Page ID's could very well change.

However, I've had no luck so far on resolving my other "issue" on the Archive page: adding a date before the title when using "postbypost". I'm open to suggestions and hints for that one.

Thanks in advance.

fromtheranks Jun 10, 2009 10:37 PM

Minor oops in my code. I added the remark incorrectly -- it showed up on the Home page. :o

This works:

Code:

<?php  if ( !is_page('Archives') && !is_page('Sitemap') ) { // modified 6/10/09 by DPH to drop byline from archives and sitemap pages ?>
                        <?php bfa_post_byline(); // Post Byline: To edit the output, see functions/bfa_post_parts.php ?>
<?php } ?>

I add such remarks so I can find what I tweaked if I need to go back ... I just need to add them in the right place. :)

fromtheranks Jun 12, 2009 01:09 PM

As an update, the logic for the look of the archives page content is definitely coming from wp_get_archives( ). So there doesn't seem to be a "simple" mod that I can make via Atahualpa. That makes sense now.

However.

Has anyone figured out how to "tweak" wp_get_archives( ) so, when using "postbypost" I can get a list that looks something like this?
  • <post date> <post title>

Thanks in advance.

jankph Jul 18, 2009 07:06 AM

Quote:

Originally Posted by fromtheranks (Post 8380)
Has anyone figured out how to "tweak" wp_get_archives( ) so, when using "postbypost" I can get a list that looks something like this?
  • <post date> <post title>

I'm looking for something like this, too. Is it not possible?

Flynn Jul 22, 2009 10:47 AM

wp_get_archives has "before" and "after" parameters but those are meant to be used for HTML. To include the post date try a plugin such as http://www.ardamis.com/2007/06/25/ad..._get_archives/

jankph Jul 22, 2009 04:34 PM

I downloaded and activated the plugin, but the instructions said

Edit your theme, replacing wp_get_archives('type=postbypost') with ard_get_archives();

Now, where is that? Supposedly in wp-includes/general-template.php....but I cannot find anything that looks like that in MY general-template.php...or am I wrong?

Flynn Jul 23, 2009 07:52 AM

Try replacing

PHP Code:

<?php /* Archives Pages. Displayed on a specific static page, if configured at ATO -> Archives Pages: */
bfa_archives_page('<div class="archives-page">','</div>'); ?>

in ATO -> Style & edit CENTER COLUMN -> Content BELOW the LOOP

with

PHP Code:

<?php if ( is_page('Title of Archive page') ) {
if ( 
function_exists('ard_get_archives') ) {
ard_get_archives();
}} 
?>


fromtheranks Jul 25, 2009 09:52 AM

Thanks for the tip on the plugin: http://www.ardamis.com/2007/06/25/ad..._get_archives/ and modifying ATO --> BELOW the LOOP.

However. I haven't upgraded to WP 2.8.x or Atahualpa 3.4.x yet so I couldn't do the minor surgery as suggested.

But. I did take the idea from the plugin's code (shown at the above link) and made that work for me on Atahualpa 3.3.3 by directly modifying ..\wp-includes\general-template.php.

[I know it isn't a good idea to modify core code but I haven't had time to do the upgrades so this will work until I do.]

Here's the origina "postbypost" code (the three dots indicate omitted code):

Code:

} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
...
        if ( $arcresults ) {
            foreach ( (array) $arcresults as $arcresult ) {
                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
                    $url  = get_permalink($arcresult);
                    $arc_title = $arcresult->post_title;
                    if ( $arc_title )
                        $text = strip_tags(apply_filters('the_title', $arc_title));
                    else
                        $text = $arcresult->ID;
                    $output .= get_archives_link($url, $text, $format, $before, $after);

Here's the tweaked code (changes in red). This puts the date in front of the title with a colon and space in between:
Code:

} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
...
        if ( $arcresults ) {
            $beforebefore = $before; // new 7/25/09 by DPH - see: www.ardamis.com/2007/06/25/adding-the-post-date-to-wp_get_archives/
            foreach ( (array) $arcresults as $arcresult ) {
                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
                    $url  = get_permalink($arcresult);
                    $arc_title = $arcresult->post_title;
                    $arc_date = date('m/d/Y', strtotime($arcresult->post_date));  // new 7/25/09 by DPH
                    $before = $beforebefore . '<span class="recentdate">' . $arc_date . '</span>' .': ';  // new 7/25/09 by DPH
                    if ( $arc_title )
                        $text = strip_tags(apply_filters('the_title', $arc_title));
                    else
                        $text = $arcresult->ID;
                    $output .= get_archives_link($url, $text, $format, $before, $after);

If you wish to have the date afterwards modify the logic per the sample code on the plugin site above.

Note: for brevity's sake, the closing brackets have been omitted from the above sample, so if you wish to make a similar tweak don't copy this code verbatim; instead, backup general-template.php and then add the three lines of code in red placing them where shown.

You can see an example of this in use at my site: www.fromtheranks.com. Click on the "Archives" tab on the Page Bar.

Hope this helps.


All times are GMT -6. The time now is 06:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.