Category: wordpress tutorial

i’m not here to judge — change is tough. but i will say that gutenberg makes the content creation experience so fun

that said, you might have a site where gutenberg isn’t necessary (a bunch of metadata options for each page/post type)

so instead of installing an older version of wordpress (v4.9.*), use this function to disable gutenberg and revert to the classic editor

Read more »

i admit that i was afraid of upgrading to the new gutenberg editor… either preventing my site from upgrading to v5.0 or even adding a function to keep the classic editor alive.

in developing my site, i wanted to include performance enhancements. namely, lazyloading using lozad. however, out of the box, the image block markup looks like this:

Read more »

there are a few assumptions:

  1. you already have your tumblr consumer key, secret, oauth token, and oauth token secret
  2. i used this tutorial as a starting point: http://techslides.com/tumblr-api-example-using-oauth-and-php
    • i didn’t use the callback.php nor the connect.php files in the zip
  3. create a private (password-protected) tumblr blog and set up each editor as a contributor to it
    • private because you don’t want viewers to happen upon the tumblr site (you’ll lose hits on your own site!)

Read more »

I Google’d and checked the WordPress codex, but could not find a function that would give me the ID of an image I uploaded into a custom meta field.

The Problem

I have uploaded an image, but that image is huge. I want to be able to display the image at my predefined size. There are functions to display the post thumbnail (featured image) in any which way you want, but this is different.

This is the cleanest method I’ve found to get the attachment’s ID. With the ID, you’ll be able to use a function to display that image.
Read more »

so i’ve been using this wordpress plugin that will help your site become multilingual called qTranslate. it’s awesome. it allows you to add different translations for menus, posts, pages, widgets, etc with a little bit of effort (of course, every project is different, some php coding may be required). here’s a fairly quick startup guide

the thing is, we only need the plugin for a set of pages and that’s it… not the most ideal solution, but it’s working… or was

i found a random issue that no amount of googling could resolve… every page that didn’t require translation would display fine except for the below snippet of code

essentially, the code was using “get_posts” to display a page within a page (almost inception-like)

Read more »

so i’ve been running into a nagging issue with wordpress’ new instance of its media uploader (released in v3.5)

if i had a meta box with an image uploader, it would conflict with the standard “Add Media” button for the editor

previous code

uploader.js

jQuery(document).ready(function() {
var form_field;
jQuery('.button-upload').click(function() {
form_field = '#' + jQuery(this).next('input').attr('id');
tb_show('', 'media-upload.php?type=image&TB_iframe=true');
return false;
});

window.send_to_editor = function(html) {
imgurl = jQuery('img',html).attr('src');
if(!imgurl){
imgurl = jQuery(html).attr('src');
}
if (jQuery(form_field).length > 0) {
jQuery(form_field).val(imgurl);
}
tb_remove();
}
});

Read more »

so this came about when i was tasked to create a custom metabox for a wordpress site at work. i didn’t want the metabox to appear unless a specific template was chosen — this is so as not to confuse the person in the admin with new options they shouldn’t be messing with.

i found this solution, but it wasn’t quite working in my admin. so i put on my wordpress/php developer cap and dissected it down to the following:

Read more »

i’ve added a new feature to my site: custom post types. you can see the page here — as you can see, it’s all of my sketches i’ve done since last august

code

functions.php
first add this to allow for featured images (if it’s not already in there):

add_theme_support( 'post-thumbnails' );

This part will register the custom post type to wordpress

add_action( 'init', 'create_sketch' );
function create_sketch() {
$labels = array(
'name' => _x('Sketches', 'post type general name'),
'singular_name' => _x('Sketch', 'post type singular name'),
'add_new' => _x('Add New Sketch', 'Sweet'),
'add_new_item' => __('Add New Sketch'),
'edit_item' => __('Edit Sketch'),
'new_item' => __('New Sketch'),
'view_item' => __('View Sketch'),
'search_items' => __('Search Sketches'),
'not_found' => __('No Sketches found'),
'not_found_in_trash' => __('No Sketches found in Trash'),
'parent_item_colon' => ''
);

$supports = array('title', 'editor', 'revisions', 'thumbnail', 'comments');

register_post_type( 'sketches',
array(
'labels' => $labels,
'public' => true,
'supports' => $supports
)
);
}

Read more »

originally found this on josh stauffer’s site. just wanna add to my site so i can pull it up easily

$slug = basename(get_permalink());