Trying to use Ternary operators with WP Conditionals
Syntax is wrong you need to phrase it like so: condition ? TRUE : FALSE so change your code to : echo is_home() ? ‘1’ : ‘0’;
Syntax is wrong you need to phrase it like so: condition ? TRUE : FALSE so change your code to : echo is_home() ? ‘1’ : ‘0’;
Here is some quick first draft code for populating a dropdown from the Google Font API, I do not know about the options framework so this will not deal with that. 1. Get an API Access Key from Google Your request will need a valid key, you can follow the instruction here on how to … Read more
The first menu item typically is the parent item and shares the name with that item, you can however manually update the entry directly in the $submenu variable, like so.. add_action( ‘admin_menu’, ‘jp_create_admin_pages’ ); function jp_create_admin_pages() { global $submenu; add_menu_page(‘Members’,’Members’,’manage_options’,’members’,’jp_handle_admin_members’); add_submenu_page(‘members’,’Membership Types’,’Membership Types’,’manage_options’,’membership_types’,’jp_handle_admin_membership_types’); $submenu[‘members’][0][0] = ‘All Members’; } That way your parent keeps the original … Read more
@s_ha_dum is right, the ajax plugin api is the way to go. I ran into this issue myself with a dynamic js file I was generating a little while ago. Basically you would enqueue your style as follows: wp_enqueue_style( ‘dynamic-css’, admin_url(‘admin-ajax.php’).’?action=dynamic_css’, $deps, $ver, $media ); Then create a function to load your dynamic css file: … Read more
I figured out how to fix my problem. In my nginx config file (/etc/nginx/nginx.conf) I added client_max_body_size 100m; at the end of the #Basic Settings in the http {} section. I hope this answer will help some of you and please tell me if there is any better solution to this problem.
WordPress offers its own mailing system. I suggest you use that instead of PHP’s native mail. wp_mail accepts five arguments: wp_mail( $to, $subject, $message, $headers, $attachments ); So your code can be written this way: // Set the headers $headers[] = ‘From: ‘ . get_option(‘admin_email’); // Add the addresses to an array foreach($emails as $mail) … Read more
While you can add the snippet directly to header.php, a better choice is probably the wp_head action which should be triggered in any well-made, modern theme. Using this hook allows you to insert the snippet without actually modifying your theme. It might look something like this: function wpse_282929_conditionally_print_ga_snippet() { if ( ! some_conditional_tag() ) { … Read more
from https://businessbloomer.com/woocommerce-conditional-logic-ultimate-php-guide/ global $woocommerce_loop; if ( is_product() && $woocommerce_loop[‘name’] == ‘related’ ) { add_action(‘woocommerce_after_shop_loop_item_title’,’your_custom_function’,20); }
Here’s one way: You can look at has_shortcode() and find the parsing there: preg_match_all( “https://wordpress.stackexchange.com/” . get_shortcode_regex() . “https://wordpress.stackexchange.com/”, $content, $matches, PREG_SET_ORDER ); using the get_shortcode_regex() function for the regex pattern. For non empty matches, you can then loop through them and collect the full shortcode matches with: $shortcodes = []; foreach( $matches as $shortcode … Read more
You want to include wp-load.php or wp-blog-header.php not wp-settings.php or wp-config.php directly. If you look at the code in wp-load.php you will see why. wp-load.php looks for wp-config.php in several different places, including one level above the rest of the install. If you include wp-config.php directly the script will fail if wp-config.php has been moved. … Read more