GithubHelp home page GithubHelp logo

conditional-tags-shortcode's Introduction

=== Conditional Tags Shortcode ===
Contributors: shazdeh
Plugin Name: Conditional Tags Shortcode
Tags: shortcode, context, conditional, conditional-tags, page
Requires at least: 3.1
Tested up to: 5.4.1
Stable tag: 0.2

A shortcode to display content based on context.

== Description ==

With this shortcode you can take control of where the content is displayed.

= Usage =
You can use all the <a href="http://codex.wordpress.org/Conditional_Tags">conditional tags</a> WordPress provides. Checkout examples below.

Show text only on the homepage:
<code>[if is_front_page] The text [/if]</code>

Show text only on the About page of the site:
<code>[if is_page="about"] The text [/if]</code>

Show only on the category archive view:
<code>[if is_category] The text [/if]</code>

You can add "not_" before the conditional tag to reverse the logic, example:
Show on all pages of the site except the homepage:
<code>[if not_is_front_page] The text [/if]</code>

= OR =

Using multiple parameters, the content is displayed when either of the conditions are met ("OR" comparison), for example, show text on both category and tag archive pages:
<code>[if is_category is_tag] The text [/if]</code>

= AND =

To set multiple conditions you can nest the shortcode, for example show text only on homepage AND if the user is logged in:
<code>[if is_user_logged_in][if is_front_page] The text [/if][/if]</code>

Show a link to wordpress.org site, only on single post pages and only on mobile devices:
<code>[if wp_is_mobile][if is_single] <a href="http://wordpress.org/">WordPress</a> [/if][/if]</code>

= has_term_{taxonomy} =

You can use this to check if the current post in the loops belongs to a custom term in the desired taxonomy. See: https://codex.wordpress.org/Function_Reference/has_term

Example, check if current post has the "jazz" term in the "genre" taxonomy:
<code>[if has_term_genre="jazz"] The text [/if]</code>

== Installation ==

1. Upload the `menu-item-visibility` directory to the `/wp-content/plugins/` directory
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Enjoy!

conditional-tags-shortcode's People

Contributors

shazdeh avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.