Answers for "how to querry in wordpress"

PHP
5

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
}
/* Restore original Post Data */
wp_reset_postdata();
Posted by: Guest on September-27-2020
0

wordpress add block from single.php

// GET a post or page with blocks or whatever and print it 
//on your single.php or other wp file 
$reuse_block = get_post( 123 ); // ID of the post
$reuse_block_content = apply_filters( 'the_content', $reuse_block->post_content);
echo $reuse_block_content;
Posted by: Guest on May-25-2020

Browse Popular Code Answers by Language