69 posts
  • Exclusive Author
  • Has been a member for 1-2 years
  • Europe
athis says

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

1090 posts The Last Man Standing
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 10 and 49 items
  • Sold between 50 000 and 100 000 dollars
  • Beta Tester
ImanGM 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
  • Exclusive Author
  • Has been a member for 1-2 years
  • Europe
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
  • Exclusive Author
  • Has been a member for 1-2 years
  • Europe
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.

1090 posts The Last Man Standing
  • Elite Author
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 10 and 49 items
  • Sold between 50 000 and 100 000 dollars
  • Beta Tester
ImanGM 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
  • Exclusive Author
  • Has been a member for 1-2 years
  • Europe
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 ;)
by
by
by
by
by
by