Filtering the WordPress Menu

You can filter both the <li> tag and the contained anchor tag in a WordPress menu using the ‘nav_menu_css_class’ and ‘nav_menu_link_attributes’ filters.

The ‘nav_menu_link_attributes’ filter is not well documented – but very useful nonetheless.

This example shows how to add the required classes for a Bootstrap 4 menu markup – in which the <li> requires the class nav-item and the anchor tag requires the class nav-link:

<?php
add_filter( 'nav_menu_css_class', function($classes) {
$classes[] = 'nav-item';
return $classes;
}, 10, 1 );

add_filter( 'nav_menu_link_attributes', function($atts) {
$atts['class'] = "nav-link";
return $atts;
}, 100, 1 );

 

WordPress Custom Post Types: Archive Pages

Featured image of article: WordPress Custom Post Types: Archive Pages

Don’t you hate it when you’re banging your head against a problem you’ve already solved? When you forget one key piece of information that unlocks the problem in an instant?

In this case, I set up a site with custom WordPress post types (in this case “Projects”), and I was trying to create category archive pages to display project teasers. Continue reading “WordPress Custom Post Types: Archive Pages”

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.

Rationality

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.

References

  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.