Add theme features to custom post type?

(10 posts) (3 voices)

  1. I have created a "Practitioner" custom post type, defined in a plugin. In this case, a practitioner is a service provider at a shared treatment facility. The custom post represents everything about a practitioner, stored in custom fields, plus whatever they want to say about themselves in the excerpt and post body fields. The intent is for practitioners to be able to update their information on their own, without running the risk of breaking the page, or having to know HTML, etc. The page is rendered by hooking into the mysite_before_page_content action.

    Along with it, I have created a "services" taxonomy. This allows a practitioner to be associated with the service(s) they provide. Then, on the Services page, I can list all available services by querying the taxonomy, and for each one, all of the practitioners that offer that service. But I haven't built that part, yet. But it gives you an idea of where I want to go with this.

    The one thing I've run into that I could really use some help with: the edit page does not include the same things that the Page and Post edit pages do. Specifically, the shortcode generator and the theme options, etc.

    Is there a non-hackish way to cause my custom post type to look an act just like a post when you are editing it in the admin?

    Also, is there a way to force full-width layout?

    Posted 6 years ago #
  2. Elliott
    Support

    Hello jarrowwx,

    For the shortcode generator you'll want to open up /wp-content/themes/[your_theme]/lib/admin/admin.php and add your custom post type to the array on line 115,

    new mysiteShortcodeMetaBox( $pages = array( 'page', 'post', 'portfolio' ) );

    To add the post options open up /wp-content/themes/[your_theme]/lib/admin/options/meta-post.php and add your custom post type to the array on line 6,

    'pages' => array( 'post' ),

    Posted 6 years ago #
  3. So there is no way to do it via hooks, I have to tweak the source of the theme in order to make it work?

    Posted 6 years ago #
  4. Elliott
    Support

    Are you wanting to use a child theme? http://mysitemyway.com/docs/index.php/Using_Child_Themes

    Posted 6 years ago #
  5. If that works, that would be slick. But it looks like I would still have to tweak the parent theme code in order to get the behavior I want, won't I? Because I can't redeclare the list of post types to apply it to.

    Sounds like an opportunity to enhance the MySiteMyWay code base. If this line:

    new mysiteShortcodeMetaBox( $pages = array( 'page', 'post', 'portfolio' ) );

    became


    if ( !function_exists( 'mysite_apply_shortcode_generator_to_post_types' ) ) :
    function mysite_apply_shortcode_generator_to_post_types() {
    return array( 'page', 'post', 'portfolio' );
    }
    ...
    new mysiteShortcodeMetaBox( $pages = mysite_apply_shortcode_generator_to_post_types() );

    then the child theme could declare a function mysite_apply_shortcode_generator_to_post_types and control which types are relevant.

    But can I alter $meta_boxes[pages] from the child theme? Time to do some experimenting.

    Posted 6 years ago #
  6. Okay, I have to get the syntax right, but still...

    I moved my plugin code into a child theme. I'm able to see the new post type in the admin (Yeah!), I can see and edit my custom post (Yeah!), but when I try to view the post, I get a 404 error! (huh!?)

    Same code, but running as a child theme, it doesn't work. Has anyone ever seen anything like that before?

    Posted 6 years ago #
  7. Yes, people have. I just had to update my permalink structure, which caused a flush, and all is well. Cool. More experimenting...

    Posted 6 years ago #
  8. Okay, I was able to make my child theme display the shortcode generator by overriding the function that defines the list of post types to display it for.

    However, I can't see an easy way to modify the $meta_boxes array programmatically from the child theme. Is there one?

    Posted 6 years ago #
  9. Elliott
    Support

    We'll see if we can make it easier in the next update jarrowwx.

    Posted 6 years ago #
  10. fgr
    Member

    Hello Elliott,

    I have the same problem like jarrowwx.

    1. Which solution do you suggest for showing metabox and short code generator in custom post type? Still this one?

    For the shortcode generator you'll want to open up /wp-content/themes/[your_theme]/lib/admin/admin.php and add your custom post type to the array on line 115,
    
    new mysiteShortcodeMetaBox( $pages = array( 'page', 'post', 'portfolio' ) );
    
    To add the post options open up /wp-content/themes/[your_theme]/lib/admin/options/meta-post.php and add your custom post type to the array on line 6,
    
    'pages' => array( 'post' ),

    2. You wrote

    We'll see if we can make it easier in the next update

    Is this easier method already available? If not, can you give us an estimate when this will be?

    Thanks and kind regards.

    Thomas

    Posted 3 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme