Custom Post Types & Thesis 2

Featured image of article: Custom Post Types & Thesis 2

I love to build WordPress websites, and I really love the Thesis framework. Thesis takes care of the heavy-lifting and allows you to focus on the style and functionality of a website.

When Thesis 2.0 came out last year, it was a big surprise – the framework changed almost beyond recognition. At first, change was painful. All those comforting little familiar nuances were gone.

I felt that after 3 years learning how to deploy WordPress sites using Thesis, it was back to the drawing board.

However I needn’t have worried – after a couple of weekends digging in to Thesis, I realized that the framework is more powerful than ever.

Custom Post Types & Thesis

Most recently, I needed to create WordPress custom post types. Thesis 2 handles this with ease – when you create a custom post type, Thesis 2 recognises this and automatically generates a HTML template for the new post type.

This template can be customised to your heart’s content, and the Thesis query box helpfully allows you to select posts, pages or your custom post types – giving you full control over how your custom post types are displayed.

Once my custom post types were set up, I needed to create a customised back-end, so that site administrators could easily add data. For example, in my “Person” custom post type, I needed it to be easy for administrators to add biographical data. In a similar way, I needed associated content to be linked – for example, the administrator should be able to select projects that the person has been involved with, and these should be displayed on that person’s page.

Once the backend has been built and content added, it isn’t immediately obvious how to display this data on the site using Thesis. By using Thesis hooks, you can create PHP functions to call the custom field data, and have this fire in the correct place in your page template.

Thesis Hooks: Custom Field Content

Here’s how you get custom fields into your Thesis page template:

  • Add the function that calls your custom field in the customs.php file of your active skin
  • Link to this to your page template by means of Thesis hooks

For example, to display the Advanced Custom Fields field “job_title” in a Thesis 2 template, add the following code to your skin’s custom.php. The “get_field” and “the_field” functions are part of the Advanced Custom Fields plugin API, and the slug for my custom field is “job_title”.

function add_job_title_field() {

  //Next line: don't run function if field is empty
  if (get_field('job_title')!= ""){

	  <h3 class="subheading"><?php the_field('job_title'); ?></h3>

add_action('thesis_hook_container_job_title_top', 'add_job_title_field');

You then add the hook “job_title” – as referenced in ‘thesis_hook_container_job_title_top’ – where you want the field to display. You do this by entering the hook name in the “Unique Hook Name” field of the container in question, as shown in the screenshot below:

Job Title Screenshot from 2013-08-07 17:17:36

I created empty containers that use hooks to fire the functions, and I can attach a class or ID to the container for styling purposes. Sorted!

This is a really useful function – made me realise how powerful Thesis 2 is…


WordPress Plugins: Linux Mint Localhost

Featured image of article: WordPress Plugins: Linux Mint Localhost

A local installation of WordPress is a useful way of developing sites – you can muck about on your site without the world seeing the results of your experimentation.

Although you could develop your site on a remotely hosted test server, working on a locally installed version of WordPress is more private. In addition, working locally is usually quicker and more productive – you can clip along at a rapid pace even when your internet connection is patchy.

When I recently set up a localhost WordPress installation on Linux Mint 14, I encountered problems when trying to upload and activate plugins.

When the filesystem can’t be accessed directly, WordPress will ask for permission to access files via FTP. This results in a dialog like this when you try to update a plugin (or carry out similar actions):

WordPress request FTP accessThis problem occurs when Apache is running under a different user to the WordPress filesystem owner. WordPress doesn’t have permission to change your files directly – so it asks for FTP access.

This is problematic in a localhost install – where files are not accessed via FTP. Luckily, there’s a fairly simple solution.

Find Out the Apache User

  1. Create a text file called whoami.php
  2. Paste this into whoami.php:    
    <?php echo(exec("whoami")); ?>
  3. Save whoami.php in your localhost root (typically /var/www/ on Ubuntu or Mint)
  4. Navigate to http://localhost/whoami.php
  5. This will return the user that your instance of Apache is running under

Give the User the Correct Permissions

The easiest fix to this issue is to give file ownership of the directory holding the WordPress files to the user that is running Apache. In my case, the Apache user was www-data, and the WordPress installation in question was located at /var/www/test.

Open a terminal (ctrl+alt+t) and enter:

sudo chown -R www-data /var/www/test

Where “www-data” is the user returned by whoami.php and “/var/www/test” is the path to the folder that contains your WP installation.


Social Behaviour: Our Evolutionary Heritage

Featured image of article: Social Behaviour: Our Evolutionary Heritage

Human social behaviour is rooted in our biology. Our genes provide us with an inherited framework for action – strongly influencing our response to environmental factors.

But inheritance is about more than just genes.

We pass on ideas, customs, norms and heuristics. We learn rules of thumb and “common sense” from our society – and this cultural inheritance has an important influence on behaviour.

Social and behavioural “rules” emerged as our species developed. Selective pressure meant that these rules were adapted according to our environment. Those of us with the most efficient behaviour were most likely to have offspring – who in turn would inherit the genetic and cultural (mimetic?) recipe for success.

In this way, human behaviour was shaped by environmental pressures over countless generations.

Big Brains and Social Interaction

Primates are the most social of all animals and human beings are easily the most social of the primate species. There is a correlation between social activity and brain size, both between species and over the span of human development. In general, the more social the animal, the bigger the brain.

Within primates there is a relationship between brain size and the size of the social group. It also appears that as humans became more social, brain size increased.

The computational demands of a highly complex social structure may have provided a strong evolutionary stimulus in favour of larger brain size (1,2,3). Did our increasingly complex social life confer a selective advantage, which in turn created evolutionary pressure in favour of large brains?

Or did the evolution of large brains allow human beings to be more social? Whether or not the relationship is causal, there is certainly a correlation between social activity and large brains.
Evolutionary Psychology: Social Behaviour in Context

Evolutionary psychology is a relatively new discipline that seeks to explain human psychology (including social interaction) from a modern evolutionary perspective. Much of human behavior is seen as the output of psychological adaptations that evolved to solve recurrent problems in human ancestral environments (4).

The evolutionary perspective has made a strong contribution to social psychology, and is increasingly being seen as providing a rational framework for understanding person perception, social cognition, attitudes, altruism, emotions, group dynamics, leadership, motivation, prejudice, intergroup relations, and cross-cultural differences.

The field of evolutionary psychology is related to a range of emerging disciplines including neuroeconomics and pyschoneuroendocrinology.

Psychoneuroendocrinology (what a word!) is a particularly favourite of mine – the discipline helps to explain such things as sickness behaviour, depression and athletic overtraining (more on this in a later article!). PNE helps break down the artificial boundaries between psychology, endocrinology and neurology. What’s more, it’s pretty clear that our psychoneuroendocinological responses to the world have been strongly shaped by our ancestral environment.


As economists will testify, human beings do not act with perfect economic rationality. Studies in neuroeconomics have shown that emotions are especially important when making strategic choices.

These emotional decisions should be understood in an evolutionary context as guiding appropriate behaviors for our highly social species. The cognitive regions of our brains are involved in making cost-benefit-type economic choices – but these decisions are informed by older brain regions that mediate emotions, motivation, and attention 4. I’ll write a future article outlining why you should probably not make investment decisions after getting a back-rub.

Time-Shifted Rationality

From an evolutionary psychology perspective, “irrational” social (and economic) behaviours can be explained. This is known as “Time-Shifted Rationality” and the concept may be important when setting up social networks or establishing pedagogical relationships.

It is also a concept that might help explain “irrational” economic behaviour, and may prove valuable in the business context. It is highly likely that there are innate constraints and limits to human social relations (and indeed rationality in a general sense).

These constraints result from our evolutionary heritage. Furthermore, many social decisions (including economic ones) may appear contextually irrational – but can be explained as preferences which would have maximised the chance of survival in an ancestral environment.

For example, altruism 1,2 and risk aversion 3 can be explained in terms of increasing survivability in the context of tight-knit human groupings in ancestral environments.

Cavemen in Suits (or Jeans)

In genetic terms, we are essentially neolithic hunter gatherers living in a modern environment – and much of our psychology is shaped by this fact. We are adapted to the environment in which our species spent much of it’s history – the advent of agriculture and the modern age are extremely recent events in terms of our biological heritage.

For more than 99.8 % of our history, human beings were hunter-gatherers – and this legacy shapes our social interactions as well as our genetic inheritance.

Next I’m going to write an article on the natural group size for human beings – or why the number of Facebook friends you have corresponds to the number of inhabitants in an average neolithic village.


  1. Frith, Uta, and Chris Frith. “The social brain: allowing humans to boldly go where no other species has been.” Philosophical Transactions of the Royal Society B: Biological Sciences 365.1537 (2010): 165-176.
  2. Dunbar, Robin IM. “The social brain hypothesis.” Brain 9 (1998): 10.
  3. Dunbar, Robin IM, and Susanne Shultz. “Evolution in the social brain.” science 317.5843 (2007): 1344-1347.
  4. Zak, Paul J, and Jacek Kugler. “Neuroeconomics and International Studies: A New Understanding of Trust.” International Studies Perspectives 12.2 (2011): 136-152.