Why aren’t my posts showing?

This doesn’t work the way you think it does because get_pages doesn’t do what you think it does. First, understand that all pages, all content, in WordPress is really a “post”. A “Page” is just a special type of post. Now, in a normal environment, you wouldn’t call “get_” anything. This is why you’re confused, … Read more

How can I get the content of the home page?

alternative to using the default loop in the front-page.php template: if( have_posts() ) { while( have_posts() ) { the_post(); the_content(); } } you could try using: if( get_option( ‘page_on_front’ ) ) { echo apply_filters( ‘the_content’, get_post( get_option( ‘page_on_front’ ) )->post_content ); } https://codex.wordpress.org/Option_Reference

Using “setup_postdata” with “get_template_part” does not work

For those who aren’t creating a query with get_posts() you may need to reference the global $post variable first before using setup_postdata(). Here is an example shortcode using a foreach loop and iterating through an array of post objects from an ACF Relationship field: function your_shortcode() { //reference global $post first global $post; $featured_posts = … Read more

How do you modify Page Template?

All code will be in the template. That is how custom templates work. Altering the output those templates is a code edit except where the templates have been written to include the post body, or meta fields, etc. But don’t go to Appearance->Editor and start hacking away. First, if this isn’t your theme you are … Read more

Change site template from php

If I understand your question, you should use this inside your foreach: $argument_to_pass_to_switch_theme = $theme->get_stylesheet(); Just taking a look at the documentation: The function wp_get_themes()… “…returns an array of WP_Theme objects based on the argument.” This class WP_Theme has a method get_stylesheet(), which… “…returns a string with the directory name of the theme’s “stylesheet” files, … Read more