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.
Yes you need some arguments defined. A good place to easily get your loops defined is: https://generatewp.com/wp_query/ Here’s an example of some arguments used. // WP_Query arguments $args = array ( ‘post_type’ => array( ‘post’ ), ‘nopaging’ => true, ‘posts_per_page’ => ‘3’, ‘ignore_sticky_posts’ => true, ); // The Query $query = new WP_Query( $args ); … Read more
Was looking for get_cross_sells()
From ACF Documentation: /* * Conditional Statement */ if( get_field(‘field_name’) ) { echo “do something”; } else { echo “do something else”; } So…to check if something is “NOT” checked is just the else of the above.
Have you tried wp_reset_query(); after each loop? Please provide complete code for your template then we may can help.
Are you sure you want to do this in this manner? Normally a section like this might be written to the page template somehow and not called via the content editor. That being said, this should do what you need: add_shortcode( ‘show_xyz_news’, ‘xyz_news_query’ ); function xyz_news_query() { $args = array( ‘posts_per_page’ => 3, ‘category_name’ => … Read more
The function get_theme_mod() returns information. Since you want to assign it and not echo it to the screen, we can remove the echo and PHP tags: $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 4, ‘product_cat’ => get_theme_mod( ‘vatname’, ‘Clothing’ ), ‘orderby’ =>’date’, ‘order’ => ‘ASC’ ); That should fix your query. … Read more
Every theme is different – there is no standard way of naming (or even using) a template part. You would be better off using your own markup and default styles, but allow theme authors to override it with hooks & filters.
All other things being equal, your page file “page-projets.php” will display a page with a slug = “projets”. So… what is the contents of that page?
You should change your get_posts to WP_Query. You are making a lot of queries because you’re running setup_postdata is running its own set of queries to get the post data from the posts you got through get_posts. This can be avoided by using WP_Query instead. Based on your code, you should have something like this … Read more