WP_QUERY

Calling your Query While or Foreach While <?php $query = new WP_Query($args); ?> <?php while ( $query->have_posts() ) : the_post(); ?> <div> <?php $query->the_post(); get_template_part( ‘content’, get_post_format() ); ?>...

Start Making A WordPress Plugin From Scratch

This post requires developer discretion. The file names are written as an example for this post. As long as you make sure your files are been linked up correctly, you can name your files whatever you like. There’s loads of comments to help you along the way. You...

Step 1 Adding a Plugin

function my_admin_menu() { $page_title = ‘Clear Stock’; $menu_title = ‘Clear Stock’; $capability = ‘manage_options’; $menu_slug = ‘/clear_stock’; $function = ‘clear_stock’; $icon_url = ”; $position =...

PHP Dates broken down parameters

<?php echo date_default_timezone_set(‘UTC’); /* The terrminology for this function h : 12 hour format H : 24 hour format i : Minutes s : Seconds u : Microseconds a : Lowercasw am or pm l : Full text for the day F : Full text for the month j : Day of the...

WordPress Update meta_value by meta_key

// Clear Stock function clear_current_stock(){ // Declare the $wpdb var global $wpdb; // Run My SQL Query (My Query is setting the meta value for stock to zero) $wpdb->query(“UPDATE wp_postmeta SET meta_value = 0 WHERE meta_key = ‘_stock'”); // Check...

Check User Role ( if statement included )

<?php $user_id = get_current_user_id(); if (!empty($user_id)) { $user = wp_get_current_user(); $role = ( array ) $user->roles; // echo $role[0]; if ($role[0] == ‘free-client’ OR $role[0] == ‘administrator’) { //code here… } }...

Pin It on Pinterest