WordPress.org

Ready to get started?Download WordPress

Forums

Modifing wp_get_archives() (2 posts)

  1. Sergio De Falco
    Member
    Posted 6 years ago #

    Hi people,

    I'm tring to modify the main wp_get_archives() in order to request an author id and show their posts like in the main function.

    I know the the_author_posts_link() is similar but I'd like to view archives like on the wp_get_archives() function.

    So... I made some modifies to general-template.php:

    1) after:

    $defaults = array(
    		'type' => 'monthly', 'limit' => '',
    		'format' => 'html', 'before' => '',
    		'after' => '', 'show_post_count' => false
    	);

    I added:

    $curauth = get_userdata(get_query_var('author'));

    2) I modified:

    $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );

    In

    $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish' AND post_author = " . $curauth->ID, $r );

    3) I also added:

    $url = $url . "&author=" . $curauth->ID;

    After:

    $url = get_month_link($arcresult->year, $arcresult->month);

    Ok everything seems to work, but the result page doesn't appear like an archive page, but just like a filtered main page.

    How can I solve this?

    Thanks :)

  2. Sergio De Falco
    Member
    Posted 6 years ago #

    Anyway, doesn't work with permalinks on :(
    The link it gives me http://server.com/2008/02/&author=1

    Instead
    http://server.com/2008/02/?author=1 redirect to the global author page and isn't permalink compliant.

Topic Closed

This topic has been closed to new replies.

About this Topic