Site logo

Archived topic

How to insert a php into html

3 replies · Started by David on June 8, 2022

Viewing posts 1–4 of 4

Hello,
i have a memberpage, where loggedin users can change their data.
And i like to add a section with all of the comments, THIS actual user has writen.

Here is a PHP code, that should work:

<?php
if ( is_user_logged_in() ) {
    $user_id = get_current_user_id();
    $args = array(
        'status' => 'approve',
        'order' =>  'DESC',
        'user_id' => $user_id
    );
    $comments = get_comments($args);
    foreach($comments as $comment) :
        echo '<p>'; 
        echo($comment->comment_author . '<br />' . $comment->comment_content);
        echo '</p>';
    endforeach;
}
?>

But how do i get this into a page?
Or maybe you have a better idea how to reach this goal.

Thank you,
David

Hi Leo, thank you for the shortcode trick.
It works fine.

No problem :)

This archived topic is closed to new replies.