get comments and get posts in loop

get_comments accepts an array of arguments, you are passing an integer. If you want to retrieve all comments for a post use: get_comments( array(‘post_id’ => $post->ID, ‘status’ => ‘approve’) ); To get an already formatted comment list, is easier use the wp_list_comments() function, instead of another foreach cycle (code from codex): echo ‘<ol class=”commentlist”>’; //Gather … Read more

How do I create a link that will always show the latest post?

If I understand well you want to show the last post (one post) from one of the 3 post types you have, using a dynamic url like http://example.com/latest. First of all lets add a filter to ‘do_parse_request’ filter: add_filter( ‘do_parse_request’, function( $bool, WP $wp ) { $home_path = trim( parse_url( home_url(), PHP_URL_PATH ), “https://wordpress.stackexchange.com/” ); … Read more

When and Where is `global $post` Set and Available?

Global $post var is set by WP::register_globals() method. It is called by WP::main() method, on its turn called by wp() function that is called when wp-blog-header.php is loaded. If you look at the graph @Rarst built, on the left, you can see where wp() function is called. In terms of hooks, global post variable is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)