What function does the loop of displaying posts?

The loop http://codex.wordpress.org/The_Loop Here’s a standard loop you can customize using WP_Query. <?php // The Query $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) { echo ‘<ul>’; while ( $the_query->have_posts() ) { $the_query->the_post(); echo ‘<li>’ . get_the_title() . ‘</li>’; } echo ‘</ul>’; } else { // no posts found } … Read more

How does WP knows which template to use for a page

The native logic of template choice is contained in file aptly named template-loader.php. It processes the current context and calls respective get_*_template() functions, until a match is found. This process results in what is called Template Hierarchy. However as it was pointed out this only covers native core logic. Plugins can wildly customize this process … Read more

Create an if statement based on page_id

You don’t need if (is_home) – the homepage doesn’t use page.php as a template, and you’re checking for page ID anyway, which the homepage shouldn’t match. To check what page you’re on you can use is_page() with the page ID. if(is_page(1111)) { display text 01; } elseif(is_page(2222)) { display text 02; }

how to add a page to a plugin?

You can use the activation hook and call function wp_insert_post() class MyPlugin { static function install() { $my_post = [ ‘post_title’ => ‘My page title’, ‘post_content’ => ‘My page content’, ‘post_status’ => ‘publish’, ‘post_author’ => 1, // Set author id here ‘post_type’ => ‘page’, ]; wp_insert_post( $my_post ); } } register_activation_hook( __FILE__, [ ‘MyPlugin’, ‘install’ … Read more

Query page: preserve page formating

You’re comparing apples to oranges here. Both queries do the exact same thing, but are presented through different code. Your query: <?php $my_postid = 663;//This is page id or post id $content_post = get_post($my_postid); $content = $content_post->post_content; $content = apply_filters(‘the_content’, $content); $content = str_replace(‘]]>’, ‘]]>’, $content); echo $content; ?> Merely pulls some content out of … Read more

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