Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // in function.php of your wp theme
- function test_shortcode_func( $atts ){
- $a = shortcode_atts( array(
- 'value' => 0,
- ), $atts );
- $num = (int) $a['value'];
- switch ($num) {
- case $num % 7 === 0:
- if ($num % 11 === 0) {
- return "[LongRead]";
- }else{
- return "[Long]";
- }
- break;
- case $num % 11 === 0:
- if ($num % 7 === 0) {
- return "[Long]";
- }else{
- return "[Read]";
- }
- break;
- default:
- return "[{$num}]";
- }
- }
- add_shortcode( 'test_shortcode', 'test_shortcode_func' );
- /*
- [test_shortcode value="5"]
- [test_shortcode value="7"]
- [test_shortcode value="11"]
- [test_shortcode value="77"]
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement