WordPress.org

Ready to get started?Download WordPress

Forums

how to add Comment Form in author page (12 posts)

  1. mohammad50
    Member
    Posted 1 year ago #

    hello ,
    i use this help to create author list and profile page
    http://codex.wordpress.org/Author_Templates#About_Current_Author

    now how can i add comment form to author pages ?

    this is my profile link in site :
    http://www.simafun.com/author/mohammad-moradpour/

    excuse me for my bad english

  2. bcworkz
    Member
    Posted 1 year ago #

    The comment system is setup to be associated with a post ID. Since the author page is a variant of the main page which displays many posts, there is no single post ID to associate the comments with, so it will not work.

    It may be feasible to create an author page for each author. Since pages are a type of post, they have an ID, so comments could be associated with it. Then you could probably just use get_template_part() with your theme's comments template. But there will be some loose ends to tie up. Like the /author/ permalinks will not lead to your author pages unless you do an url rewrite. There's likely several other issues I'm not thinking of.

  3. mohammad50
    Member
    Posted 1 year ago #

    hi again ,
    tnx for your help

    as you say , i use separate file for my profile : author-1.php
    (author-{id}.php)
    so my ID is 1

    then i use this code to show comments.php to my author page :
    <?php get_template_part( 'comments' ); ?>

    now comment form appear in my author pages, but when i send a comment , comment go to this post instead of my profile!! :
    http://www.simafun.com/?p=25975

    i add google translator to my site for translate persian to english.

  4. bcworkz
    Member
    Posted 1 year ago #

    Uh oh!! That is probably what WordPress considers the current post. I'm not that knowledgeable on how pages are handled. You may need to have your page manipulate query_posts() or WP_Query so that the post ID of your page registers as the current post. That is how the comments template knows where it is. It's quite easy to show a comment form and have it go to the right place once you determine the correct post ID. The problem is displaying the related comments themselves.

    One problem is normal queries exclude pages, your query will need to specify post type as "page" in addition for querying for your page. I warned you there would be loose ends, I'm sorry one is a pretty big one.

    Also, FIY, the ID the comment template is using is the post ID. Your user ID of 1 has nothing to do with anything relevant to this topic.

    On further thought, you may be better off creating a post that looks like an author page for each author. That will solve the comment issue. But how to display all the author's posts inside a post? Perhaps a custom post type, so that the post type template can restart a fresh query and run a loop based on it. The post title will need to be the author name, and you'll need a rewrite to send /author/name/ traffic to simply /name/

    Looks like you're in for query hacking either way. What looked like an easy hack is turning out to not be so easy.

  5. mohammad50
    Member
    Posted 1 year ago #

    plz feedback this problem to developer for define comment form in author page as a normal page :((

  6. bcworkz
    Member
    Posted 1 year ago #

    I was about to make a request on your behalf, so I did a topic search and found many similar requests. The response in general was that it's theme related and not the concern of core developers. The impression was given that comments on pages was easy to implement.

    Aware of your issues, I created an author page as you did on my test installation. To my surprise, I found that with my theme, a heavily tweaked twentyeleven, comment support is already in place. It works properly with out my doing anything!

    Now that I think about it, when you request a page, a query is generated that will return that one page. Thus comments should be assigned to that page's ID automatically, as that is the current "post".

    There must be something odd about your theme's comment form that is preventing it from finding the proper post ID. So hopefully, a solution will be easier than I thought initially after your first misstep.

    I did notice my page template uses <?php comments_template( '', true ); ?> instead of get_template_part(). You should try that and see if it helps.

  7. mohammad50
    Member
    Posted 1 year ago #

    i use below code in twenty eleven themes author.php file too, but comment form not appear :
    <?php comments_template( '', true ); ?>

    please give your author.php file to me .

  8. bcworkz
    Member
    Posted 1 year ago #

    author.php was not involved in my experiment. The author archive has no post ID, so comments cannot be associated with it. Instead, I created a page with the author biography on it. I just used the default template from the twentyeleven theme, page.php. It should reside in your installation as well unless you removed the twentyeleven theme.

    However, to make this work completely, we would need a custom page template that contains an author query loop to display the author's posts. As long as we remember to wp_reset_post_data() when done, I believe there will be no significant issues.

  9. mohammad50
    Member
    Posted 1 year ago #

    ok i make a page for my profile
    i user this code after first loop :

    <?php wp_reset_postdata(); ?>
    	   <?php wp_reset_query(); ?>

    and it work very well.
    tnx dear good luck

  10. bcworkz
    Member
    Posted 1 year ago #

    Good result! I'm pleased you got it working.

    If you're still checking this thread, I have a couple questions for you regarding right to left scripts. I don't know anyone personally who uses one these scripts and is computer literate.

    Do I need to do anything special to serve Persian content besides have the correct language files and setting WPLANG to 'fa_IR'? My installation is English based but content is fully served as UTF-8. What about static html files? Anything on my server that needs to change to serve static Persian content?

    Do you know in what ways the Persian WordPress distribution is different than the English set to use fa_IR? I actually know nothing of Persian, I am interested only in the technology needed to facilitate websites in various languages.

  11. mohammad50
    Member
    Posted 1 year ago #

    i download my wordpress from http://www.wp-persian.com
    it is fully traanslated to persian .

    but if you need a technology to facilitate websites in various languages, use this plugin :
    you can download it from : sitepress-multilingual-cms.zip

    i test it on local and work well :

    it automatically rtl and ltr site direction and you can add how many language you want to use .

  12. bcworkz
    Member
    Posted 1 year ago #

    Thank you my friend. Looks like just what I need. Cheers.

Topic Closed

This topic has been closed to new replies.

About this Topic