How to specify the path for require_once in a child theme?
Since 4.7 get_theme_file_path() is the right function to use: require_once get_theme_file_path( ‘gateway/config.php’ );
Since 4.7 get_theme_file_path() is the right function to use: require_once get_theme_file_path( ‘gateway/config.php’ );
Note this is mostly a PHP programming question about arrays and is better asked on e.g. Stack Overflow. As shown in the docs array_push() acts on the array and takes multiple parameters which get added as array values. It doesn’t add key => value pairs to associative arrays, and it doesn’t return the array itself, … Read more
I’ve never used it, but it looks like get_main_site_id is what you want to figure that out, so therefore your code might look like: $mainSiteId = get_main_site_id(); foreach ($user_blogs AS $user_blog) { if ($userblog->site_id != $mainSiteId) { echo ‘<li><a href=”‘.$user_blog->siteurl.'”>’.$user_blog->blogname.'</a></li>’; } }
You assumed get_field would always return images, but what if there are no images to return? $images = get_field(‘fl_gallery’); $image = $images[$no]; The code never checks $images to see if it’s empty, or an error value. On top of that, what if it returned images, but it returned 3 images, and $no is 4? You … Read more
I think it would be helpful if you could explain why you’re generating courses out of edits that a user’s doing on his profile. The simplest solution seems to be a frontend form that just allows a user to create new posts or edit existing ones rather than going for this alternative solution where you’re … Read more
It’s very simple: Just assign the value of shortcode_atts() (which is an array) to a variable and use it to access the shortcode attributes in the same way you access the items in any other arrays: $atts = shortcode_atts( array( ‘no’ => 1, ), $atts ); // Use $atts[‘no’] to get the value of the … Read more
If it’s outputting some PHP from functions.php but not the whole file then likely you’ve just got mismatched PHP opening/closing tags – <?php and ?> somewhere, or potentially even mismatched string quotations. You need to edit that file in a text editor and look carefully around the point it’s starting to output PHP for mismatched … Read more
Depending on the scope of your project, I would recommend either using ACF (Advanced Custom Fields) which will allow you to create custom fields in your user based on their level, which you can then output into your theme. The outputting part though will require some coding knowledge to do. The other option is to … Read more
There are a few things omitted in the above solution, like defining the most params of wp_mail. Also I didn’t want to send yet another concurrent email, but instead attach the csv directly to the mail that wpcf7 sends. I think this is the cleaner solution. Here’s my take: add_filter( ‘wpcf7_before_send_mail’, ‘add_form_as_attachment’, 10, 3 ); … Read more
The solution is as @Tom J Nowell mentioned to launch WP Cron via crontab (and disable it on user visits).