How can I create an entirely new, separate display of posts?

Here’s what I ended up with: Everything within my child-theme file example-single.php for displaying individual posts within a template file example.php a new template as a destination for new routes. new routes and a filter on ‘pre_get_posts’ All of the following can simply go in functions.php in the child theme: function example_routes() { // add … Read more

How can one use variables in a template or template part without polluting the global scope?

I feel there is a bit of confusion — let me try and clarify some key concepts. A WordPress installation can potentially run huge amounts of 3rd party code. Code you can’t control. That leads to a high chance of naming collisions. That’s why WordPress coding standards suggest to “namespace” functions and variables declared in … Read more

How can I produce multiple webpages with a different output based on one entry/Page/custom Page?

Query string parameters are a helpful friend in this situation. It will allow you to keep the same single-$posttype.php file for both formats of the page. So if someone visits your page using the URL: https://yourwebsite.com/events They will see your normal webpage for visitors. But if someone uses the URL: https://yourwebsite.com/events?seminar=true They will see something … Read more

Homepage not loading correctly, only after refreshing

You can change your current theme to storefront and check whether the scripts and styles are properly enquequed. use this format to enqueque style and scripts and inspect the code for debugging class yourPluginName { public function __construct() { add_action(‘wp_enqueue_scripts’, array($this, ‘enqueue’)); } public function enqueue() { wp_enqueue_script(“jquery”); wp_enqueue_script(‘my-js’, plugins_url(‘/script.js’, __File__)); wp_enqueue_style(‘my-theme’, plugins_url(‘/style.css’, __File__)); }