Tech Blog

The Tech Blog contains web programming tips & tricks.


Remove Post Tags from WordPress Admin

Remove from Posts sub menu in left side WordPress Admin Menu:

Remove Tags column from List of Posts in Admin:

Remove Tags Side Box when editing/creating post:

 

Single Post Template Functions

Get the date – always prints date even if on second post on same day. $post_id is optional if inside of posts loop. See https://codex.wordpress.org/Formatting_Date_and_Time for $format value.

does not print date if displaying second post on same day in loop.

List current post categories with separator between each:

List current post custom taxonomies with separator…

Continue reading »

Retrieve Pages by Path or Template in WordPress

By Template:

Check if got anything and use it from query above:

By Path:

 

WordPress Menu Functions

Returns an array of menu items. $menu parameter is slug or id of Menu created in WordPress. $args is from here: https://developer.wordpress.org/reference/functions/get_posts/, which isn’t very helpful for filtering what menu items you want to display.  This function returns an array that you can display manually, but does not include any data about which menu…

Continue reading »

Category Template Tags

The following functions can be used on the category.php template to display information about the current category. Display Current Category Title on category.php:

Display Current Category Description:

Get Current Category Object:

Use Category Object returned above to get ACF fields on category:

Display Category Link – works for custom taxonomies and…

Continue reading »

Handy WordPress Functions

A collection of WordPress functions I use often. Link to Home:

Include another php file:

*File name separated on ‘-‘ between two inputs to function. So if named include-content-blocks.php call is:

Custom field images (not featured):

Get image values in array instead of outputting image:

Retrieving featured images is a…

Continue reading »

WP_Query – Order by multiple custom fields

The Code

Always call

afterwards to reset the global $post value. Otherwise, any attempt to retrieve data from the page will return null.

Slow WooCommerce Site Caused by wc_session Data

One of my client’s sites had been running slowly and I was not able to run an update script after upgrading a plugin without timing out. In the process of moving the site to a new host, I found the [wp-prefix]_options table was really big – over 300,000 entries. After doing some digging, I found…

Continue reading »

Categories

Search Tech Blog