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

Can I use require() function in a template file?

You are seeing this error because you are requireing the file with a relative path. As @Mark Kapulun pointed out in the comments you should not use relative paths when requireing files. Instead you want to be explicit and use absolute paths. Use get_template_directory() which returns the Absolute path to the directory of the current … Read more

Using a different template per Custom Taxonomies for single term archive pages

I would intercept the template loader at template_redirect: function wpse53892_taxonomy_template_redirect() { // code goes here } add_action( ‘template_redirect’, ‘wpse53892_taxonomy_template_redirect’ ); Then, you would check to see if the query is a custom taxonomy: if ( is_tax() ) { // This query is a custom taxonomy } Next, get the term object, and find out if … Read more

/images/image.jpg not working in sidebar

PHP code won’t run inside of a text widget. There are plugins that will let you do that, but this type of thing is strongly discouraged. Add this code to your functions.php file, or better yet, make it a simple little plugin: // Enable the use of shortcodes within widgets. add_filter( ‘widget_text’, ‘do_shortcode’ ); // … Read more

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