Show shortcode in a post

Shortcode is a markup language used by WordPress which is used to embed dynamically generated content, often from plugins, into your posts. Shortcode is denoted by being wrapped in square brackets, [ and ].

To show shortcode in a post, you need to escape the square brackets by doubling them, [[ and ]].

(The square brackets in this comment are shown as is, I think because they’re surrounded by spaces instead of actual code.)

Creating and Adding to an Image Gallery

To create an image gallery:

  1. go to Pages > Add New.
  2. click Add Media.
  3. click Create Gallery (on the left column).
  4. shift-click the images to add
  5. and click the “Create a new gallery” button.
  6. Add captions if you like.
  7. click Insert Gallery.
    This will take you back to the Add New Page page and you’ll see inserted shortcode like this:
    [gallery type="rectangular" ids="70,77,90"]
  8. click Publish.

To add an image to an existing gallery:

  1. go to Media
  2. click on the image you want to add. (This will open the Attachment Details page.)
  3. Look at the URL and note the item number.
    The URL will look like this:
    http://blog.stephenfranklin.info/wp-admin/upload.php?item=120
  4. close the Attachment Details page and go to Pages > All Pages.
  5. click on your page title to open the Edit Page page.
  6. insert the item number into the shortcode ids tag. Like this:
    [gallery type="rectangular" ids="120,70,77,90"]

increasing the media file upload limit

I’m running WordPress 4.0 on Ubuntu 14.04 on an EC2.

I see this is a common issue, but I’ve been unable to change the file upload limit from 8MB to anything.
I’ve tried these suggestions:

  1. Change the max upload line in your php.ini file
    (/etc/php5/apache2/php.ini and/or /etc/php5/cli/php.ini)
memory_limit = 128M
upload_max_filesize = 128M
post_max_size = 128M
file_uploads = On

I’ve tried smaller integers also.

  1. Create the PHP.ini file in the wp-admin directory.
  2. Open or create the .htaccess file in the root folder and add the following code:

php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 300
php_value max_input_time 300
  1. Add the following code in the theme function’s file:
@ini_set( 'upload_max_size' , '128M' );
@ini_set( 'post_max_size', '128M');
@ini_set( 'max_execution_time', '300' );
  1. Copy the php.ini file in wp-admin to php5.ini.

At every try I’ve reloaded apache2 and I’ve even rebooted the machine. Everything is up to date. I’ve disabled all my plugins, and tried different themes. I’ve even re-installed wordpress. I’m really stumped. Any more suggestions?


This stackoverflow suggestion to make a plugin worked:
increase max upload limit in wordpress

Create a file called increase-upload-limit.php in wp-content/plugins/increase-upload-limit/ and write this:

<?php
/* Plugin Name: Increase Upload Limit */

add_filter( 'upload_size_limit', 'b5f_increase_upload' );

function b5f_increase_upload( $bytes )
{
   //return 33554432; //  32 mebiBytes 
    return 134217728; // 128 mebiBytes
}

Then go to wp-admin and activate it.

Note that the PHP file doesn’t have the closing angle bracket. That’s how it works in WordPress for some reason. I’ll have to find out why eventually.

hosting a photo from Amazon S3

Hosting images on s3 for wordpress:
sudo apt-get install php5-curl
sudo service apache2 restart

Install these plug-ins in wordpress:
Amazon Web Services
Amazon S3 and CloudFront

1)Create a new IAM user and grant access to the specific services which this plugin will use (e.g. S3).
Go to AWS IAM > Create New Users > “wordpress”.
Download the credentials (User Name, Access Key Id, Secret Access Key).
2) Click on the user “wordpress” > Attach User Policy:
Add AmazonS3FullAccess
3) Copy the folowing code to your wp-config.php and replace the stars with the keys.

define( ‘AWS_ACCESS_KEY_ID’, ‘********************’ );
define( ‘AWS_SECRET_ACCESS_KEY’, ‘****************************************’ );

4) In wp-admin, go to AWS > S3 and Cloudfront. Hopefully it will already have access to your S3 buckets.
Choose the S3 bucket you want to use.

Here are my settings:
unchecked: Bucket is setup for virtual hosting (more info)
checked: Set a far future HTTP expiration header for uploaded files (recommended)
CloudFront Settings: not used.
checked: Copy files to S3 as they are uploaded to the Media Library
checked: Point file URLs to S3/CloudFront for files that have been copied to S3
checked: Remove uploaded file from local filesystem once it has been copied to S3
unchecked: Always serve files over https (SSL)*
checked: Copy any HiDPI (@2x) images to S3 (works with WP Retina 2x plugin)

And here’s an S3 hosted photo:
DSC_0232

  • The wp-admin Media menu seems not to work over https, so you get the broken image icon instead of the actual image, and they won’t upload to S3 or link to a post. But after unchecking the SSL option, uploading, and linking, the SSL option seems to have no effect on the posted images. The only difference in the html of the post is that the SSL option uses a href=https... instead of http.

Here’s another S3 photo:
DSC_0242