WordPress Plugin Development - Part 26b - Modular Custom Post Types

Поделиться
HTML-код
  • Опубликовано: 11 дек 2024

Комментарии • 61

  • @brajbhooshan7349
    @brajbhooshan7349 3 года назад

    Hi alecad
    I watch your WordPress plugin development from scratch it is imagine but face some problems that video 0:57 line number 25, WordPress through error " can not access offset of type string on string" please guide me how to solve it

  • @lilitgrigoryan6020
    @lilitgrigoryan6020 5 лет назад +1

    You are amazing.After study Laravel , oop php for me very helpful use Wordpress such way with composer php package.Thanks very much.

    • @alecaddd
      @alecaddd  5 лет назад +2

      I use Laravel every day :D
      Implementing this approach in WordPress makes life soooo much easier when handling multiple methods and classes.

  • @stpengineering
    @stpengineering 6 лет назад +1

    here we go!

  • @TimothyCareyDV
    @TimothyCareyDV 6 лет назад +2

    I've made my own database tables for WordPress in the past. How are you start getting rid of options saving from all this code?

    • @alecaddd
      @alecaddd  6 лет назад

      What do you mean by "getting rid of options saving"? I always recommend using the built-in database structure of WordPress, mostly because of scalability and compatibility with future versions, other themes or plugins. Having a custom table increases drastically the complexity and debt of your code.

    • @TimothyCareyDV
      @TimothyCareyDV 6 лет назад

      This plugin I am creating is for only one website for one company and they want it on separate database tables. Now the admin checkboxes area or other settings might still be in the options table. I think I will look at your code on your git. They want to store student registration and scores or drew and such.

  • @johnnysilva8861
    @johnnysilva8861 6 лет назад +1

    Hello! Great tutorial! you could do a totorial wordpress development + atomic design??? It's going to be really cool!

    • @alecaddd
      @alecaddd  6 лет назад

      Good idea, I'll think about it for future series :D

  • @MyCasper1234567890
    @MyCasper1234567890 6 лет назад +1

    Hi Alessandro, Im developing my own plugin with your tutorials,
    I need to know if in the future we will see how the plugin visually interacts with the frontend, or we are just programming within the wp-admin, thanks.

    • @alecaddd
      @alecaddd  6 лет назад +7

      Oh yeah, we're gonna code a lot of front-end stuff.
      Some of those are:
      - Custom widgets
      - Testimonial Contact Form
      - Custom Ajax Login
      - and other things I can't remember right now :D

  • @homamhomam1879
    @homamhomam1879 6 лет назад +1

    amazing man>>>

  • @TimothyCareyDV
    @TimothyCareyDV 5 лет назад +1

    How would it change things by having Gutenberg editor? I don't like Gutenburg,

    • @alecaddd
      @alecaddd  5 лет назад

      Lots of people don't like Gutenberg unfortunately, eh eh.
      With this current setup, your custom post type should open the classic editor by default. Around the end of this series I showed how to activate Gutenberg by default for custom post types and custom taxonomies.

    • @TimothyCareyDV
      @TimothyCareyDV 5 лет назад

      @@alecaddd Is that where you can add certain pieces of information to your post from somewhere else like the database? I'd like to store a dropdown of link names and address, key and value of my sources for articles. So I can just choose the correct source from sources I've used before. And update that list also. We do that through custom post types and custom taxonomies? Also something good to work at when wanting to find articles to post. Past sources.

  • @engineser6470
    @engineser6470 6 лет назад

    hi alessandro, i have done everything as in tutorial but i receive an error in wordpress see here taht is only a cutout.
    why does it not accept the strings? i checked the code also with our repo but no failure?
    Warning: Illegal string offset 'post_type' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 227
    Warning: Illegal string offset 'name' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 230
    Warning: Illegal string offset 'singular_name' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 231
    Warning: Illegal string offset 'menu_name' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 232
    Warning: Illegal string offset 'name_admin_bar' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 233
    Warning: Illegal string offset 'archives' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 234
    Warning: Illegal string offset 'attributes' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 235
    Warning: Illegal string offset 'parent_item_colon' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 236
    Warning: Illegal string offset 'all_items' in C:\xampp\htdocs\wordpress\wp-content\plugins\ssl-soul-plugin\inc\Base\CustomPostTypeController.php on line 237

    • @engineser6470
      @engineser6470 6 лет назад +1

      i found the failure with the array declaration

    • @alecaddd
      @alecaddd  6 лет назад

      Cheers

  • @Andreas-qc7py
    @Andreas-qc7py 4 года назад +2

    If anyone is having the "register_post_type was called incorrectly" as i was having. I solved it by adding a small if statement at the method "storeCustomPostType()" .
    First you define the $option = get_option( 'YOUR OPTION NAME ' );
    Then you wrap the entire $this->custom_post_types[] = array(); inside this if statement:
    if ( ! empty($option)) {
    // Enter the $this->custom_post_types[] here.
    } else {
    return;
    }
    I thought it was something about the 'title' => 'STRING' at the setFields -> 'post_type' being more than 20 characters. I tried fixing that but didn't help as my $option variable was never being set before a user types a custom post type so the $option['post_type'] was just being NULL, which i think was the problem.
    Anyway i am not yet quite sure why my if statement actually works and i'm not sure it will work for anyone else, anyway... Try it if you have the problem.

  • @bonkedyan5627
    @bonkedyan5627 5 лет назад

    I get this error message: Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'Inc\Base\CustomPostTypeController' does not have a method 'activate'

    • @alecaddd
      @alecaddd  5 лет назад

      Check my source code on GitHub if you have any issues

  • @makebehphilip4573
    @makebehphilip4573 6 лет назад

    Hi,
    My code throws this error:
    Notice: register_post_type was called incorrectly. Post type names must be between 1 and 20 characters in length. Please see Debugging in WordPress for more information. (This message was added in version 4.2.0.) in C:\wamp64\www\237First_wordpress\wp-includes\functions.php on line 4147
    I hadn't any errors prior to this video. Any suggestions?

    • @alecaddd
      @alecaddd  6 лет назад

      What's the name of the Post type are you trying to create?
      Check my source code on Github to see if you have any typos.
      Also, be sure to run PHP 7+ as I'm not 100% sure it'll work with PHP 5.6

  • @kamalhines
    @kamalhines 6 лет назад +1

    WOW Keep em coming...

  • @ylebrac
    @ylebrac 6 лет назад

    Hi Alessandro, any idea why settings are registered twice when I click the Submit button? I have checked with you code and saw no difference!?

    • @alecaddd
      @alecaddd  6 лет назад

      Uh, no idea, sorry. Did you try copying my code from GitHub?

  • @samahmohamed9574
    @samahmohamed9574 6 лет назад

    Hi Alecad, Thanks for the great tutorial. I have a question. Is it possible to add custom fields to custom post types and have the user enter data in that field and include the information in that field while displaying custom post type in the archive page or other locations with the loop? Im not talking about the plugin, simply including this option by default for a specific post type in the theme. I cannot find such tutorials on youtube, however, many videos are there that use a plugin.

    • @alecaddd
      @alecaddd  6 лет назад +1

      Hi, thanks for watching.
      Did you watch my Premium Theme development series? In those videos, I show how to create the Contact Custom Post Type, how to add some custom fields to it and allow the users to add data to those fields, all without the use of a plugin.
      Check that playlist and you'll learn everything you need.

    • @samahmohamed9574
      @samahmohamed9574 6 лет назад

      I will look into that. Thanks alex

  • @djangoWarri0r
    @djangoWarri0r 5 лет назад

    hey Alee, great work! its little off topic but I need it to work. The IOS Toggle is not working on my side, copied files from your repo , changed the key and cert , gulp watch is working fine, everything looks good but it keeps showing those small checkboxes we did in the beginning.

    • @sandro6691
      @sandro6691 5 лет назад

      Try disabling caching. Are you using chrome?

    • @djangoWarri0r
      @djangoWarri0r 5 лет назад

      @@sandro6691 cleared cache and tested on both firefox and mozila still same checkbox!

    • @sandro6691
      @sandro6691 5 лет назад

      Did you confirm that gulp is outputting the code correctly into assets/mystyle.js & assets/mystyle.css?
      if you open the files and scroll 4/5ths to the end in the mystyle.js you should see "ul.nav-tabs li.active" somewhere in the long line of code and go right to the end of .css and you should see "ui-toggle" a couple of times.

    • @alecaddd
      @alecaddd  5 лет назад +1

      Yeah, be sure the compiled file is properly included in your admin page and it comes with all the custom classes we created.

  • @SabbirAhmed-cm6hk
    @SabbirAhmed-cm6hk 6 лет назад

    Notice: register_post_type was called incorrectly. Post type names must be between 1 and 20 characters in length. Please see Debugging in WordPress for more information.

  • @SabbirAhmed-cm6hk
    @SabbirAhmed-cm6hk 6 лет назад

    Undefined index: has_archive in ---> facing this problem

  • @honeybadger6522
    @honeybadger6522 6 лет назад

    Hey now I have a problem that says ''register_post_type was called incorrectly''. This is creating problems and I'm having problem to move on.

    • @alecaddd
      @alecaddd  6 лет назад

      Check my source code on GitHub if you have any problem.

    • @honeybadger6522
      @honeybadger6522 6 лет назад

      Did that all. Tried to solve it through Google and other site. Still not working out. Really need help.

    • @Reislust
      @Reislust 6 лет назад

      Same issue here.
      Notice
      : register_post_type was called incorrectly. Post type names must be between 1 and 20 characters in length. Please see
      Debugging in WordPress
      for more information. (This message was added in version 4.2.) in XXXX\wp-includes\functions.php on line 3897
      The error only appears when I didn't fill the form on the Custom Post Type Manager page.

    • @Reislust
      @Reislust 6 лет назад

      Same error appears if you make the name too long. Needs an check to clear the error.

    • @honeybadger6522
      @honeybadger6522 6 лет назад

      @@Reislust Was that a solution?? I don't get it. But Yeah I think that works.

  • @chriscarton4728
    @chriscarton4728 5 лет назад

    Custom Post Type declaration may inspire an episode of Black Mirror.

  • @rohankumarsahu933
    @rohankumarsahu933 6 лет назад

    What next lesson going to be??

    • @alecaddd
      @alecaddd  6 лет назад +1

      +Rohan Kumar Sahu same topic, will be up on Monday

  • @juliekikass
    @juliekikass 6 лет назад +1

    Hi thank's for your videos! I just have a really important problem! Impossible to see the CPT on the menu and on the database. It is ok for the plugin but I don't see anny issue.
    I have spend two days on : I'm gonna be crazy !
    This is the last repo if you have some time :( github.com/Djoulay/Wordpress-plugin
    Thank's (if you don't have time I totally understand!)
    Sorry for my English...

    • @alecaddd
      @alecaddd  6 лет назад

      Hi, thanks for watching my videos.
      So, the CPT appears in the administration area and you're able to create and edit Post types?
      What does it mean it doesn't appear in the database?
      Can you check your wp_posts table and order by post_type column?

    • @juliekikass
      @juliekikass 6 лет назад

      @@alecaddd thank's for your help!
      After 3 days....
      I have found :
      "Do pay close attention to not having your custom post type identifier exceed 20 characters though, as the post_type column in the database is currently a VARCHAR field of that length."
      I have changed : public function storecpt() and public function registercpt() => it works !
      Thank's for your help and very good job your my boss !!
      I just saw that there was the solution in your comments! I'll have to sleep and stop watching your great videos!

  • @XerosXIII
    @XerosXIII 5 лет назад

    anyone encounter Undefined index: has_archive or public or any other fields... go for the next video
    wasted time trying to debug it lol

  • @live18india12
    @live18india12 5 лет назад

    Notice: register_post_type was called incorrectly. Post type names must be between 1 and 20 characters in length. Please see Debugging in WordPress for more information.

    • @alecaddd
      @alecaddd  5 лет назад

      Check my source code on GitHub to see if you have typos.

    • @live18india12
      @live18india12 5 лет назад

      @@alecaddd. Ya the error is fix now. BTW your way of explanation is awesome. A man with lots of patience..

    • @sandro6691
      @sandro6691 5 лет назад

      What did you do to fix it? I looked through my code and couldn't find an issue so copied the code from github to be sure but I'm still getting the error.

    • @julienm406
      @julienm406 5 лет назад +1

      hi dude, i got this error too, it was simple to resolve it : in the menu 'CPT Manager' (right below the Dashboard), the option 'Custom Post Type ID' was longer than 20 characters, i changed it, and now it works fine

    • @sandro6691
      @sandro6691 5 лет назад

      @@julienm406 Thanks mate! You're a legend! I'm doing these again anyway to get a better grasp of what's going on so I'll remember that when I get to it :)