Skip to content

Instantly share code, notes, and snippets.

View jabaltorres's full-sized avatar

Jabal Torres jabaltorres

View GitHub Profile
@jabaltorres
jabaltorres / wp-display-categories.php
Created February 24, 2019 03:55
How to display wordpress categories
<?php
// How to display categories
$args = array(
'taxonomy' => 'test',
'orderby' => 'name',
'order' => 'ASC'
);
$cats = get_categories($args);
@jabaltorres
jabaltorres / wp-display-image-captions.php
Created February 24, 2019 04:07
Display WP featured image captions and descriptions
<?php
/* Only display to logged in users */
if ( is_user_logged_in() ) {
/* Displaying the image caption and description */
$thumb_img = get_post( get_post_thumbnail_id() ); // Get post by ID
echo '<p>The Caption: ' . $thumb_img->post_excerpt . '<br>'; // Display Caption
echo 'The Description: ' . $thumb_img->post_content . '</p> '; // Display Description
/* Displaying the image alt text */
<?php
// JT Test - being used on demos/forms/forms.php
function validate_jt_test_form($jtMessage) {
$errors = [];
if(is_blank($jtMessage['name'])) {
$errors[] = "Name cannot be blank.";
} elseif(!has_length($jtMessage['name'], ['min' => 2, 'max' => 255])) {
$errors[] = "Name must be between 2 and 255 characters.";
}
@jabaltorres
jabaltorres / jt-data.json
Last active October 8, 2019 02:55
This is being used in web fun
{
"thumbnails": [
{ "client" : "Digital Meaning",
"description" : "Digital Meaning",
"role": "UI Design, Web Development",
"imgSrc" : "https://jabaltorres.com/assets/img/thumbnails/Digital-Meaning-thumbnail.png",
"linkHref" : "https://www.jabaltorres.com/digital-meaning/",
"extLink" : false
},