Tag: wordpress

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 »

This is one of the worst bugs I’ve encountered in a while. The worst because you really don’t know exactly where the issue can be fixed…

If you go to your site’s RSS feed (http://YOUR_SITE_URL/feed), you might see this message:

XML Parsing Error: XML or text declaration not at start of entity
Location: http://YOUR_SITE_URL/feed
Line Number 3, Column 1:
<?xml version=”1.0″ encoding=”UTF-8″?><rss version=”2.0″
^

Vague… i know Read more »

say you have 10 group names, labeled ‘$group_1’, ‘$group_2’, etc. and you want to display each of them. a quick way to do that is to use dynamic variables (aka variable variables)

for ($i = 1; $i < 11; $i++) {
echo ${'group_' . $i};
}

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 »

There are some tutorials out there similar to this, but WordPress has since updated their media uploader, making those tutorials obselete. This code is essentially a combination of the best ones I’ve found

Javascript

first, you’ll want to save this code into a .js file, say “uploader.js
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&amp;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 »

finally took care of a nagging part of my site… the top slideshow. it wasn’t responsive before and now it is

it’s based off the responsive slider plugin. i had to make a minor change to it so it would show six slides per page load, choosing randomly from the library of slides. by default, it would show x amount of slides, where x is set in the settings > reading section (“Blog pages show at most”)

default

$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'menu_order' ) );

updated

$slides = new WP_Query( array( 'post_type' => 'slides', 'order' => 'ASC', 'orderby' => 'rand', 'posts_per_page' => 6 ) );

i actually didn’t expect the 'orderby' => 'rand' part to do what it did (choose randomly from the library of slides), but i’m pretty happy with it. this way, i can upload as many slides and not have to worry about ordering them in any special way

'posts_per_page' => 6 is what controls the amount of slides that are shown in the slideshow

yes, i’m aware that this will be killed if i update the plugin…