13 | | |
14 | | {{{#!php |
15 | | <?php |
16 | | function get_my_comments(){ |
17 | | global $wpdb; |
18 | | $user_id = get_current_user_id(); |
19 | | $comment_results = $wpdb->get_results("SELECT comment_post_id FROM wp_comments WHERE user_id = $user_id"); |
20 | | $comments = array(); |
21 | | foreach($comment_results as $result){ |
22 | | $comments[] = $result->comment_post_id; |
23 | | } |
24 | | return $comments; |
25 | | } |
26 | | |
27 | | |
28 | | function profile_comments(){ |
29 | | ob_start(); |
30 | | $comments = get_my_comments(); |
31 | | $args = array( |
32 | | 'post__in' => $comments |
33 | | ); |
34 | | $the_query = new WP_Query( $args ); |
35 | | |
36 | | if ( $the_query->have_posts() ): |
37 | | while ( $the_query->have_posts() ): |
38 | | $the_query->the_post(); |
39 | | |
40 | | /* |
41 | | * Include the component stylesheet for the content. |
42 | | * This call runs only once on index and archive pages. |
43 | | * At some point, override functionality should be built in similar to the template part below. |
44 | | */ |
45 | | wp_print_styles( array( 'hatterassailing-content' ) ); // Note: If this was already done it will be skipped. |
46 | | |
47 | | /* |
48 | | * Include the Post-Type-specific template for the content. |
49 | | * If you want to override this in a child theme, then include a file |
50 | | * called content-___.php (where ___ is the Post Type name) and that will be used instead. |
51 | | */ |
52 | | get_template_part( 'template-parts/content', 'archive' ); |
53 | | |
54 | | endwhile; |
55 | | echo '<div class="entry-footer">'; |
56 | | the_posts_navigation( |
57 | | array( |
58 | | 'prev_text' => '<div class="post-navigation-sub"><span><i class="fas fa-backward"></i></span> Older Posts</div>', |
59 | | 'next_text' => '<div class="post-navigation-sub">Newer Posts <span><i class="fas fa-forward"></i></span></div>', |
60 | | ) |
61 | | ); |
62 | | echo '</div>'; |
63 | | else : |
64 | | |
65 | | get_template_part( 'template-parts/content', 'none' ); |
66 | | |
67 | | endif; |
68 | | $content = ob_get_contents(); |
69 | | ob_end_clean(); |
70 | | return $content; |
71 | | } |
72 | | }}} |