Is it possible to enqueue CSS files from plugin before theme’s CSS files?

It’s easy to add your plugin stylesheet after theme stylesheet. If you’re sure that your theme styles and plugin styles have the same selector weight (theme has this style .site-header { background-color: #ccc; } and your plugin has this .site-header { background-color: #f1f1f1; }) then enqueuing plugin stylesheet after theme stylesheet will work. If you’re … Read more

FacetWP group listings by custom field [closed]

I finally fixed it: <?php $state_posts = array(); while ($query->have_posts()) { $query->the_post(); $state = get_post_meta(get_the_ID(), ‘state’, true); $state_posts[$state][] = $post; } wp_reset_query(); foreach ($state_posts as $state_post => $state_title) { ?> <h1 class=”state-name”><?php echo esc_html($state_post); ?></h1> <?php foreach ($state_title as $listing => $single_listing) { setup_postdata($single_listing); $post_id = $single_listing->ID; $title = get_the_title($post_id); $distance = facetwp_get_distance($post_id); $distance = … Read more

Is it possible to group plugins into a folder?

Short answer is no. WordPress defines plugin paths allowing plugins authors to use plugin content functions to locate their files, and these are controlled by the WordPress content constants which are set in the file wp-includes/default-constants.php However, although the path are customisable, WordPress only searches this one location. The only exception to this is network … Read more

WordPress CMB2 – Run function on save

If you haven’t gotten the answer to this yet, I found the answer by sifting through the source code. I was able to hook into the post save event by using: cmb2_save_{$object_type}_fields_{$cmb_id}. This hook fires whenever you save a certain object type with a specific metabox ID. So, in your case your $cmb_id is test_metabox, … Read more

Two people sharing user in WordPress [closed]

I suspect what you actually want, is to have all content showing as being authored by the same person. So, simply create a 3rd user, and set it as the author of your posts. The revision log will keep track of who did what e.g. https://www.siteground.com/kb/change-author-post-wordpress/

Deactivate Plugin on Theme Switch

I haven’t tested this, so it might not work correctly, but the essence of what you’re trying to do is hook into the after_switch_theme hook and see if the $old_name is DahTheme. If it is, that means that the current theme isn’t DahTheme, so you want to deactivate the plugin. function wpse_after_switch_theme( $old_name, $old_theme ) … Read more

Manually add order item with fixed product_id in WooCommerce

I know is a little bit late but maybe my anwser is helpfuly for someone else. I used WordPress in version 4.9.7 and WooCommerce in version 3.4.3 To extend the buttons you can use the woocommerce action “woocommerce_order_item_add_action_buttons“. You find the declaration of that action in the file “woocommerce/includes/admin/meta-boxes/views/html-order-items.php” The following code use this action … Read more