[Resolved] Custom Author Archive Pages

Home Forums Support [Resolved] Custom Author Archive Pages

Home Forums Support Custom Author Archive Pages

Viewing 15 posts - 46 through 60 (of 64 total)
  • Author
    Posts
  • #944170
    Tom
    Lead Developer
    Lead Developer

    The redirect is only working for one author? is_author() should be true for all authors.

    Is there a link to another author page I can check out?

    #944319
    culpable

    Ah my bad. To clarify I meant standardize it so that it works for *different* authors.

    So that if I have an author named Bob, all instances of Bob’s name mentioned below the h1s will go to /Bob/ instead of /author/Bob/

    If I have an author named Jane, all instances of Jane’s name mentioned below the h1s will go to /Jane/ instead of /author/Jane/

    #944664
    Tom
    Lead Developer
    Lead Developer

    Something like that is more complex, I suggest setting up 301 redirects for each author. That way will likely be the easiest/most SEO friendly method.

    #944998
    culpable

    Fair enough Tom, that’s a good solution – although a bit more manual than I’d like.

    I realise I’m taking up a lot of you two gentlemen’s time…. but I have some good news.

    I really liked the solution David posted here https://generatepress.com/forums/topic/custom-author-archive-pages/page/3/#post-939284 as it seemed to correctly 404 the /page/*x*/ as well as only showing 5 wordpess pages. But I couldn’t figure out why it wasn’t working for me (I was getting a “Nothing found”).

    I tried doing as David suggested – I added the author.php and completely deleted my functions.php. No dice. Made sure everything was up to date (wordpress, GP, etc.), removed all code from the Elements area…. still no dice.

    I thought about the differences between David’s test site and mine. Then it hit me… David had some wordpress posts published, and I didn’t.

    As soon as I published a single wordpress posts… bingo. The author page now correctly displays the last 5 WordPress pages written by the author.

    Reading the author.php code (here), I’d bet money that it was this part:

    if ( have_posts() ) :
    	do_action( 'generate_archive_title' );
                    query_posts(array(
                        'post_type' => 'page',
                        'posts_per_page' =>5 ) 
                    );
    

    if…. have posts. I didn’t have any posts. So the code wasn’t working. Once I published a single post – even if I no indexed it, it’s now working. Excellent!

    Just a few more questions for you if you don’t mind:

    1. Is there an easy adjustment to this code so that I don’t actually need to have any wordpress posts published for it to work?

    2. Is there a way to exclude a page by ID in this author.php code?

    3. I notice that the little “snippet” that’s taken from the article before the “Read more” button is different in the author archives vs. what WordPress show posts uses (i.e. Tom’s plugin). WordPress show posts (WPSP) seems to (correctly) ignore the table of contents, while the author archives include them (making the article snippet look like gibberish). Is there an easy fix to make the snippets for the archive the same as WPSP?

    Thank you so much guys. Love your work.

    #945398
    Tom
    Lead Developer
    Lead Developer

    That’s awesome.

    1. This part of the code executes when there aren’t any posts:

    get_template_part( 'no-results', 'archive' );

    You can replace that with anything you want and it should show up if there are no posts.

    2. I think you’re looking for: post__not_in

    So your query would be:

    query_posts( array(
        'post_type' => 'page',
        'posts_per_page' => 5,
        'post__not_in' => array( 10 ) // post ID to exclude
     ) );

    3. Which snippet are we talking about?

    #945582
    culpable

    1. Ah, excellent. So there is no “have_pages()” equivalent that I can replace the have_posts() with? (i.e. check if the author has any WordPress pages, not WordPress posts)

    2. Works like a charm, thank you sir.

    3. The snippet that the author archives and WPSP takes from the article itself, just before the “Read More” button. Here’s an example here: https://imgur.com/a/CkrvTur You can see that WPSP has ignored the Table of contents, while the author archives haven’t. Your code seems “smarter”.

    Thank you very much for your time Tom 🙂

    #945646
    Tom
    Lead Developer
    Lead Developer

    1. have_posts() will work with whatever is queried, whether it’s posts or pages.

    3. Ah, that’s because it’s displaying an excerpt which will strip HTML. If you want to display the full content, you need to tell it to display the full content instead of the excerpt.

    Let me know if you need more info 🙂

    #945976
    culpable

    1. Hmmm well in that case, what explains the behavior I described here: https://generatepress.com/forums/topic/custom-author-archive-pages/page/4/#post-944998 i.e. the author archives showing “nothing found” until I published a wordpress “posts” (even though I already had wordpress pages published). Apologies for my ignorance.

    2/3. I’d like it to display the way our WPSP do (without the ToC). I’d love some help with that 🙂

    #946257
    Tom
    Lead Developer
    Lead Developer

    1. Can you link me to this nothing found page?

    2. Have you tried setting the Content type option to “Excerpt” in Customize > Layout > Blog? That should make it exactly like WPSP.

    #946541
    culpable

    1. Sure thing. Link is on this page. To reproduce this page, the only thing I did was change the only published post on the blog written by the author from published -> draft.

    2. It’s currently set to “Excerpt”

    #946592
    Tom
    Lead Developer
    Lead Developer

    1. But there are published pages attributed to the same author? It’s hard to tell without seeing the actual page.

    2. And the posts are displaying HTML? Can I see this as well anywhere?

    #946863
    culpable

    1. Yes there are published pages assigned to the author. As soon as I publish a “post” with that author, the 5 pages show up on the author archive page. As soon as I switch the post to draft, the pages disappear. The link to the author page is shown here, in the description. If you can’t see it, let me know and I’ll email it to you.

    2. Yeah sure, here is an example screenshot of a post here. I can’t show you it as an author archive atm, as I’m currently showing you how it looks with “Nothing found” (as per question 1).

    Thank you very much for your help Tom 🙂

    #947182
    Tom
    Lead Developer
    Lead Developer

    What if you add your query_posts() code above the have_posts() check?

    #947746
    culpable

    It works… kind of.

    The pages are now appearing, but I’ve lost the author name + author display picture that is typical of author archive pages, as seen here: https://imgur.com/a/cYeHYiF

    Note that this page stays the same whether I publish a WordPress “post” or leave it as a draft (remembering there are no WordPress posts currently on the site).

    #948156
    Tom
    Lead Developer
    Lead Developer

    Hmm, that’s likely happening because query_posts() is taking over the entire query. The only thing I can think of to get around it is using the pre_get_posts action I was mentioning earlier in this topic.

    I’m not even sure how your current method is preventing pagination – nothing in the function is telling WordPress not to paginate.

Viewing 15 posts - 46 through 60 (of 64 total)
  • You must be logged in to reply to this topic.