Permalinks and custom PHP application

(EDIT) Take the custom rules outside the # Begin WordPress (credit to Tim Malone) You can check if the file exists in the root and load it before the WordPress rules kick in: # check for a file, i.e register.php # load it if found and stop processing the rest of the rules with the … Read more

Add post class in custom loop (WP_QUERY)

As milo stated, I need to use the post_class function to use the post_class filter. By adding <?php post_class(); ?> to the div in my loop I was then able to successfully modify the post class. Below is my full code containing the post_class filter and the post_class function. Reference: https://codex.wordpress.org/Function_Reference/post_class <?php //Call in the … Read more

Adding my own custom template page but got white page

I think it would be best to do a template override in Woocommerce. If by single you mean a page when viewing only one product then look at the single-product.php template. The directory it needs to located is: /public_html/wp-content/themes/your-theme/woocommerce/single-product.php. You can download the template overrides from woothemes.

Every time I use wp_get_current_user() my plugin breaks

You can get current user ID easily using get_current_user_id(). $usersid = get_current_user_id(); $activity = $_POST[‘activity’]; $reason = $_POST[‘reason’]; $explanation = $_POST[‘explanation’]; For your function f2user() you can change your code to this: $current_user = wp_get_current_user(); return $current_user->ID; According to wp_get_current_user() doc, if no user is signed in, $current_user->ID would return 0.

WordPress query posts by custom post type not workng

It’s a bad use of Query you may look at this post In this case use a secondary query with your own instance of WP Query. query_posts() is not recommanded here cause it overrides the main query. <?php $args = array( ‘post_type’ => ‘instrument’, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => 1, ); $my_query = new WP_Query( … Read more

ACF Images If/else

If I understand your question correctly, I believe this is what you’re looking for: <div class=”postthumbnail”> <?php $usercrop = get_field(‘usercrop’); if ($usercrop) { $image = wp_get_attachment_image_src(get_field(‘usercrop’), ‘full’); ?> <img class=”post-thumbnail img-responsive postpic” src=”https://wordpress.stackexchange.com/questions/232716/<?php echo $image[0]; ?>” alt=”<?php echo get_the_title(get_field(‘usercrop’)) ?>” /> <?php } ?> </div> It checks the field and only displays the HTML if … Read more