Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-16-2012, 08:11 PM   PM User | #1
OGGordon
Regular Coder

 
Join Date: Oct 2009
Location: GERMANY
Posts: 134
Thanks: 29
Thanked 1 Time in 1 Post
OGGordon is an unknown quantity at this point
help with shortcode needed (wordpress)

Hey guys,

I'd like to create such a box via shortcode:
http://www.ourtuts.com/how-to-create...ss-shortcodes/

However, I want it to be "self closing" and with a text that I don't have to type everytime I want that box to appear. How can I make that??

TIA
OGGordon is offline   Reply With Quote
Old 11-16-2012, 08:51 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
Are you describing something like displaying the green info box (with the checkmark and some text on it) and then after some time (like 5 seconds) it disappears automatically?
mlseim is offline   Reply With Quote
Old 11-16-2012, 08:56 PM   PM User | #3
OGGordon
Regular Coder

 
Join Date: Oct 2009
Location: GERMANY
Posts: 134
Thanks: 29
Thanked 1 Time in 1 Post
OGGordon is an unknown quantity at this point
Quote:
Originally Posted by mlseim View Post
Are you describing something like displaying the green info box (with the checkmark and some text on it) and then after some time (like 5 seconds) it disappears automatically?
No, I meant that I want the text inside that green box with the check mark to always be the same, so I don't have to retype it over and over.

The way how the shortcode works is like this:

[success] This is the text that always should be the same [/success]

But I want to only type: [success] and the text should automatically appear without me typing it again. Hope I explained it thoroughly, my english is a little bad .
OGGordon is offline   Reply With Quote
Old 11-16-2012, 09:43 PM   PM User | #4
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
I'm sort of guessing on this one ... my untested example below.

You should have the CSS style defined in your .css file for .successCSS

.successCSS{
font-family: arial;
font-size: 20px;
}
in your style sheet properties ... you would have borders, padding, background img, etc ...


Put this in your "functions.php" file located in your theme directory.
PHP Code:

<?php 
function success_shortcode() {    
return 
'<div class="successCSS">This is the text that always should be the same.</div>';
}
add_shortcode('success''success_shortcode'); 
?>
Then in your post ....

Blah Blah Blah
[success]
Blah Blah Blah


.

Last edited by mlseim; 11-16-2012 at 09:49 PM..
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
OGGordon (11-16-2012)
Old 11-16-2012, 09:52 PM   PM User | #5
OGGordon
Regular Coder

 
Join Date: Oct 2009
Location: GERMANY
Posts: 134
Thanks: 29
Thanked 1 Time in 1 Post
OGGordon is an unknown quantity at this point
Quote:
Originally Posted by mlseim View Post
I'm sort of guessing on this one ... my untested example below.

You should have the CSS style defined in your .css file for .successCSS

.successCSS{
font-family: arial;
font-size: 20px;
}
in your style sheet properties ... you would have borders, padding, background img, etc ...


Put this in your "functions.php" file located in your theme directory.
PHP Code:

it works :D. Thank you so much!!!!

<?php 
function success_shortcode() {    
return 
'<div class="successCSS">This is the text that always should be the same.</div>';
}
add_shortcode('success''success_shortcode'); 
?>
Then in your post ....

Blah Blah Blah
[success]
Blah Blah Blah


.
it works . Thank you so much!!!
OGGordon is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:37 PM.


Advertisement
Log in to turn off these ads.