Advanced Shortcodes

Redirect to Other Page

This shortcode is very important if you want to redirect users to other pages or to external website, you have just to add this shortcode at the top of the editor to prevent users from reading the page content.

WP Brain Redirect

You can add the redirect element within the IF and Else containers to redirect users based on the logic conditions, for example: redirect users to login pages if they aren’t logged in.

Include PHP File

Imagine that you need to render the content of an HTML or PHP file within your pages or posts without creating a shortcode for each file. That’s what WP Brain Include do, it allow you to include your files within pages and posts without coding

WP Brain Include

As it’s mentioned under the fields, the path to file must be relative WordPress directory (ABSPATH), for example if you want to include a file from your theme, you should start with ‘/wp-content/themes/’ and so on.

Note:

The following elements are advanced logic shortcodes and they are only suitable for programmers, so if you don’t have coding skills, you don’t need to use them.

Trigger WordPress Actions

With the help of this element, you can now trigger your custom action at any point of pages and posts content. This shortcode is useful for programmers who want to render content linked to an action

WP Brain Actions

In the example above, all the functions linked to ‘wp_brain_test’ hook will be called, that’s equivalent to writing do_action('wp_brain_test'); in PHP, but without coding.

Repeat Elements

This shortcode is useful when you want to repeat some content or element with different index.

WP Brain Loop

The first parameter is used to define the start index for the loop, the second is for the limit of the index, and the last parameter is referencing to the index incrementing step

In programing languages, this is equal to the FOR statement and it’s arguments, so you should be familar with the syntax of this shortcode.

What’s important about WB Brain loop, is that you can use the variable $index wherever you want in the child shortcodes, and it will be replaced by the loop index.

WP Brain Loop example

The result will be equivalent to writing the following shortcodes:

[show_post id=1]
[show_post id=2]
[show_post id=3]
[show_post id=4]
[show_post id=5]

That’s all about the logic shortcodes for pages and posts, let us know what other shortcodes you need and we will add them in future release.