Update some database fields when post is saved

Best way for storing them is WordPress’ Options Mechanism. ANd best way to trigger it when a post saved is using WordPress save_post action. Example : add_action( ‘save_post’, ‘count’ ); //Execute count() when a post saved/updated function count() { your codes here … //save them to DB update_option(“lines-of-code”, $lines); update_option(“disk-space”, $diskspace); … }

submit the form to same page

name is a WordPress query var, by submitting a form with that var set, you are changing the main query. All form elements should always be prefixed with something unique to prevent clashes like this.

Geocoding an Exploded Custom Field Array

This isn’t a complete answer, but a couple of bits of advice – Don’t geocode the addresses on front-end requests, it’s a waste of cycles. An address only needs to be geocoded once, then you can store the lat/lon data with your post meta. Use a save_post hook to do the geocoding when the post … Read more

How to allow PHP In WordPress text widget

Instead you should consider using a shortcode. This is exactly the problem that shortcodes try to solve. By default, Widgets don’t process shortcodes, but that can be easily changed. add_filter( ‘widget_text’, ‘do_shortcode’ ); This would allow you to use any shortcodes in the Widget text area. Next would be to get the PHP code you … Read more

Specific Loop For 2 Within Each

i use this code in my portfolio http://pocketapps.co/ <?php $args = array( //your argument code ); query_posts($args);?> <ul> <?php $ls=0; while ( have_posts() ) : the_post(); ?> <?php if($ls%2==0): echo ‘</li><li>’; endif; ?> <div class=”app”> //your code here </div> <?php $ls++; endwhile; wp_reset_query(); ?> </ul>

functions.php not adding css to website?

I don’t know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory. For a theme, see example function add_styles() { wp_enqueue_style( ‘fontawesome-style’, get_theme_file_uri( ‘/assets/css/all.css’ ), array(), null ); } add_action( ‘wp_enqueue_scripts’, ‘add_styles’ … Read more