• Hello everyone,
    I want to add into my website posts headings with colored background like this:

    imgur.com/qZze5DR

    It will be multiple heading in every post with different titles, i have the code to make the exact design, now i want to make a shortcode to summon the colored box and i just add a title, that’s all ??

    I’m very newbie when it comes to coding, already tried some plugin generator but it didn’t helped, I’d appreciate any help to make this ‘small plugin’ work, and thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter MyWPun

    (@mywpun)

    BTW I can post the code if needed.

    Moderator bcworkz

    (@bcworkz)

    The shortcode part is pretty basic. Use the Shortcode API. You can practically use the simple example provided and insert your code to output the desired content inside the callback function. There is one caveat. Shortcodes require all output to be contained in a single returned variable. Your output code is likely a mix of HTML and PHP echo statements which output content immediately instead of collecting them in a variable.

    Fortunately, PHP provides an output buffer facility that allows you to collect otherwise immediate output into a buffer, and the buffer’s content can then be assigned to a variable. Then returning that variable satisfies the shortcode requirements.

    Then all of this needs to be contained in a plugin. Creating a basic plugin is also simple. It’s all covered in Writing a Plugin. Being new to coding, you will also struggle with proper syntax. Since most of your code already exists in various pieces here and there, you merely need to assemble the pieces into a cohesive, logical flow. Experienced coders don’t consider this sort of cut and paste programming as “real” coding, but no matter, it can get the job done until you develop better skills.

    If you get stuck or have questions, you can always come back here. Good luck!

    Thread Starter MyWPun

    (@mywpun)

    Thank you bcworkz for your reply, the shortcode i need is almost ready, all i need now is to know how to make the heading title be written directly in h3 (not paragraph), i simply edited the default CSS in the plugin Shortcodes Ultimate ??

    This is the code i’ve edited:

    .su-heading-style-default {
    	padding: 0;
    	border: 2px solid #000;
    }
    .su-heading-style-default .su-heading-inner {
    	background: #099AE3;
    	color: #FFFFFF;
    	padding: 10px;
    	border-top: 0;
    	border-bottom: 0;
    }
    .su-heading .su-heading-align-left { text-align: left; }
    .su-heading .su-heading-align-left .su-heading-inner { padding-left: 0.2em; }
    .su-heading .su-heading-align-right { text-align: right; }
    .su-heading .su-heading-align-right .su-heading-inner { padding-right: 0.2em; }
    .su-heading .su-heading-align-center { text-align: center; }

    Any tip to make the title span as h3? ??

    Moderator bcworkz

    (@bcworkz)

    Sorry for the slow reply, I was away for a few days.

    Would you please post your PHP shortcode callback code?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘I need some help to make small shortcode’ is closed to new replies.