Query wordpress posts on static page
By static page do you mean a WP page or do you mean a HTML page within the site? If it’s the first you need a page template, if it’s the latter then you need to include wp-blog-header.php into the file with php.
By static page do you mean a WP page or do you mean a HTML page within the site? If it’s the first you need a page template, if it’s the latter then you need to include wp-blog-header.php into the file with php.
I believe you’ll want to set the image as a background image on the div (with inline CSS). In your template’s PHP you can use the following to get the URL to the full-sized featured image (within the Loop, of course): $image_url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); Then to assign this image as the … Read more
you can use taxonomy-product_cat.php for product’s categories. and you can write your custom code with post-type=”product” and tax-query.
This question isn’t really great, as it’s well documented in many places, but the answer is: View the page source, and look in the “open” body tag. It should show something like: <body class=”single single-post postid-29654 … > This example the page id/post id is 29654
Google code for displaying custom post items. Fetch all the custom post items in an array and then use a simple html of a drop down and put it in a for loop which will go through all the elements of custom post type. In the value attribute of drop down use the current array … Read more
The following code will query the “blog” category for the latest three published posts and loop through these results to display the excerpt from each. $args = array( ‘category_name’ => ‘blog’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, ); $blog_posts = new WP_Query( $args ); if ( $blog_posts->have_posts() ): while ( $blog_posts->have_posts() ): $blog_posts->the_post(); // Do … Read more
Would a table of contents plugin like https://wordpress.org/plugins/table-of-contents-plus/screenshots/ work for your case?
You can run multiple nested WP_Queries as long as you reset_postdata() to get the outer loop back on track. $query_args = array ( ‘posts_per_page’ => ‘1’, ‘meta_key’ => $count_today, ‘orderby’ => ‘meta_value_num’, ); $outer_query = new WP_Query( $query_args ); while( $outer_query->have_posts() ) : // conditional if if( true ) { // change the query arg … Read more
the_title() and the_content() both include an echo. You want to build a string, so use get_the_title and get_the_content instead.
Try running the post content through the do_shortcode() function before displaying it. $args = array(‘posts_per_page’ => -1,’post_type’ => ‘edge’); $edge_array = get_posts( $args ); foreach($edge_array as $e): echo do_shortcode($e->post_content); endforeach;