Include a php file from functions.php only to homepage

You can use is_home() or is_front_page() to check the current page. $sage_includes = [ ‘lib/assets.php’, // Scripts and stylesheets ‘lib/theme_options.php’, // Theme Options ‘lib/setup.php’, // Theme setup ‘lib/titles.php’, // Page titles ‘lib/wrapper.php’, // Theme wrapper class ‘lib/shortcodes.php’ // Old Theme Shortcodes ]; if(is_home() || is_front_page()){ $sage_includes[] = ‘lib/home_shortcodes.php’; // Homeapage Shortcodes }

How do I show the featured images for my child pages on my parent pages?

Updated: You have multiple options here. You could just insert the images and child-page-titles as normal content in your parent page (this is the easiest solution) You can edit the existing page.php(or similar, depends on theme) file inside your theme folder You can create a new page-template file to use as a parent-page template You … Read more

Extend a class of a plugin

Woocommerce support sent me the solution of my problem: function unregister_parent_hook() { if ( function_exists( ‘wc_dve’ ) ) { $instance = wc_dve(); remove_action( ‘woocommerce_after_order_notes’, array( $instance, ‘exemption_field’ ) ); } }

List User order by ID in Descending order (Backend)

I first thought that pre_user_query would be that hook for the job. But I think using the equivalent of pre_get_posts, which is pre_get_users, would be suitable here. You also said you wanted to run this in admin. So we will check that before running this. function my_custom_order_users_by_id( $query ) { //Check that we are in … Read more

How to return a foreach inside a shortcode

As I said in the comment you can use buffering like this function stock_agenda() { $days = json_decode(file_get_contents(‘json_file’)); unset($days[0]); ob_start(); // start buffer ?> <table class=”table”> <thead> <tr> <th> Title </th> <th>Content</th> <th>Date</th> </tr> </thead> <tbody> <?php foreach($days as $day) { ?> <tr> <td><?php echo $day[0]; ?></td> <td><?php echo $day[1]; ?></td> <td><?php echo $day[2]; ?></td> … Read more

How to generate page content from database the right way?

WordPress is fetching current post for you, you have to only type to the right url. When you get e.g. to example.com/lorem-ipsum/ WordPress will load automatically post with title Lorem ipsum and display it using page.php template. Your page.php template should be looking something like that. <?php get_header(); ?> <div id=”content”> <?php while ( have_posts() … Read more