69 posts
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
athis says

Is there any tutorial how to put shortcodes and custom post types into plugin?

1522 posts The Last Man Standing
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Sells items exclusively on Envato Market
+10 more
ImanGM Moderator says

Hi there,

This is a quick how to ;)

  1. Create a directory and name it anything you wish ( my-shortcodes-and-cpt-plugin )
  2. Create an index.php inside it and put this content in it:
    <?php
    /*
    Plugin Name: Your Plugin Name
    Description: Your Descriptions
    Version: 1.0
    Author: Myself
    */
    include('shortcodes.php');
    include('post-types.php');
    ?>
    
  3. Then create both of the included files (shortcodes.php and post-types.php) and in shortcodes.php put your shortcodes codes, and in post-types.php enter your post types codes.
  4. Enqueue your CSS and JS files in your PHP files.
  5. Troubleshoot the probable issues.

Actually it’s not really different with what you are doing currently in your theme. You are just moving your codes into a plugin.

Just make sure that your theme will work even if your plugin is not activated.

Hope this helps you :)

Cheers,
Iman

69 posts
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
athis says

Hi there, This is a quick how to ;)
Thank you man for your help & time i really appreciate that :)
I will try as you told me .
69 posts
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
athis says

Yes it’s really help me, now it works everything is fine, and one more thing, when i publish theme do i need to put my “shortcode” plugin into theme files or separate plugin from theme, and do i need to put shortcode css and js files into plugin folder.

1522 posts The Last Man Standing
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Sells items exclusively on Envato Market
+10 more
ImanGM Moderator says

Hi,

I’m happy that it helped :) You should put the CSS and JS files in both plugin and theme and then enqueue them. Actually you should put some CSS files to make your plugin just works with other themes (So minimal) and then make your theme specific CSS codes in the theme itself.

And the best way to bundle your plugin into your theme, is to activate it with TGM plugin. This way your plugin will install almost automatically once a client install your theme and users will be able to upgrade to your latest version easily.

Cheers,
Iman

69 posts
  • Sells items exclusively on Envato Market
  • Has been part of the Envato Community for over 2 years
athis says

Hi, I’m happy that it helped :) You should put the CSS and JS files in both plugin and theme and then enqueue them…
Thanks a lot ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by