Post Layout

Post Layout lets blog owners to inject “code” into posts and pages without modify the theme and create a new “layout” for them. “Code” is everything: from simple text to AdSense Javascript, from subscription form fields to PHP code.

Post Layout now incorporates all the Post Layout Pro features. Post Layout Pro has been dismissed and you can safely replace it with the free Post Layout (from the WordPress Plugin Repository).

Most of the things can be done with the Header and Footer plugin as well.


Here a list of all the features of Post Layout Pro. This list can help you to understand when Post Layout Pro is of help for your needs.

  • mobile detection system (lets you to differentiate the code to be “injected” when the blog is accessed by mobile devices)
  • three injection positions for posts: before, in the middle and after the post content
  • post level ability to suspend the injection (overall or for each position)
  • two injection position for pages and posts when displayed on home page, category pages, tag pages: above and below the content
  • per category code: you can inject different things in different categories (for multi categorized posts, the first one returned by WordPress is used)
  • last comment code injection: what about to put an AdSense block after the last comment?
  • comment form code injection
  • generic code blocks to be used thought the category configurations with auto offline date
  • compatible with Post Layout: if you’re using the free version of Post Layout you can update to the Pro version and the settings are kept

Usage example 1: adding AdSense

You want to insert the AdSense code (is one of the common task) before the post content, when a single post is displayed.

On the options panel, find the “Code to add before the post” textarea and copy the AdSense code:


suddenly it will display in you blog:


Example 2: adding code per category

You are ready for a new affiliate marketing campain. But it is a wellness related product and your blog has a wellness category and a chemistry category too. You don’t want to put wellness ads in the chemistry posts… easy! Suppose we want to add the ads  below the post content. Find in the options panel the “Code to add before the post”, change to a desired category, and add the affiliate code.


now look at your posts: only the ones in the wellness category will have the ads. The first one is in the wellness category the second not and the latter still has the AdSense.



But, you say, i want to keep the default AdSense even if I set specific code for a category. Yes, you can of course. Add the “[ default ]” special tag in the category code block and it will be replaced with default code block. So you can merge two different code blocks in the way you prefer.


This is the result


Working examples of  Post Layout Pro can be found in this blog. Every posts show something.

You can check all posts related to Post Layout and all posts with Post Layout examples.


WordPress 2.7 has introduced comment pagination and comment thread. That leads to some issue on injection of code after the last comment. May be this feature doesn’t works well or doesn’t work at all.

If your theme is not fully compliant with the default theme structure and function calls, some injection may not work. Try Post Layout before and notify me any issue at

17 thoughts on “Post Layout

  1. Hi Stefano,

    Good to see you’re still at the plugin game… I used Post Layout years ago for some time with success.

    Looking to give it a whirl again, but wondering if it’s compatible with WP 3.9?


  2. Hello,
    I’m using wp 3.7.1 and it doesn’t work for multi author. When I clicked on save button for other author, the button was not working. Please pay attn. for this issue.


  3. Hi,
    Mobile user agent detection feature is not working properly…
    Ads are not showing on Android or Symbian user agents. But when I tried with iPhone user agent, it was working absolutely fine.
    I was stuck and found this issue. Please solve this issue.


    1. Hi,
      I’ve just fixed the pstl_mobile_type function. I just added android, s60, series60, bada, maemo to it. No these devices are getting caught by Post Layout Pro 😉

      Function updated on location: /wp-content/plugins/post-layout/plugin.php - after line 299
      function pstl_mobile_type() {
      $options = get_option('pstl');

      if (!$options['mobile']) return '';

      $agent = strtolower($_SERVER['HTTP_USER_AGENT']);
      $agents = explode(',', "elaine/3.0,android,iphone,bada,ipod,s60,series60,maemo,palm,eudoraweb,blazer,avantgo,windows ce,cellphone,small,mmef20,danger,hiptop,proxinet,newt,palmos,netfront,sharp-tq-gx10,sonyericsson,symbianos,up.browser,,ts21i-10,mot-v,portalmmm,docomo,opera mini,palm,handspring,nokia,kyocera,samsung,motorola,mot,smartphone,blackberry,micromax,uc browser,ucweb,wap,playstation portable,lg,mmp,opwv,symbian,epoc");
      foreach ($agents as $a) {
      if (strpos($agent, $a) !== false) {
      if (strpos($agent, 'iphone') || strpos($agent, 'ipod')) return 'iphone';
      else return 'pda';
      return '';

  4. Is there a way yet to remove post layout from specific pages or posts? Like an Exclude from these pages or posts section?

    For example:

    Lets say I have blog stories I wish to have my adsense injected with Post Layout. But I have a paying advertiser’s page on my site and wish to prevent Adsense from being injected via Post Layout. Is there a way to do this or can that option be added?



Leave a Reply