[Resolved] Possible to assign different layouts?

Home Support TotalPress Possible to assign different layouts?

Tagged: 

This topic contains 6 replies, has 2 voices, and was last updated by  Thomas 2 months, 1 week ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #76429

    Hi Thomas,

    Update I see I have the Page Attributes [template] in my normal pages & posts but this is not showing up  in my course units (Custom post types).

    I’m wanting to assign Sidebar | Content to only specific post type (Course Units – WP Courseware) and the rest of the site Content | Sidebar. I can see where I can set it globally but not for specific page or post… ie. Course Units.

    Also, How do we get the Post/Page options to show up on different post types (ie. Course Units)?

    #76638

    Thomas
    Founder/Lead Dev

    Hi Donny,

    You’re killing me, you realize this right? You’re killing me and on a Sunday too…lol, I’m kidding.

    Anywho, there is no way to determine what kind of custom post types any user will need or use if they choose to use a theme I have developed. So to make this easier for end users, and user’s, WordPress made it possible to assign page templates to custom post types since 4.7. Here is the instructions from the theme developers handbook: https://developer.wordpress.org/themes/template-files-section/page-template-files/#creating-page-templates-for-specific-post-types

    So if you go into wp-content/themes/totalpress/page-templates and open up sidebar-content.php you will see the folowing at the top:

    /**
     * Template Name: Sidebar | Content
     * Template Post Type: post, page, aside, audio, chat, gallery, image, link, quote, status, video
     */

    This means that the template is available to all of those post types.

    So, in order to get it to work with the custom post type your dealing with, you would change that to something like this:

    /**
     * Template Name: Sidebar | Content
     * Template Post Type: post, page, aside, audio, chat, gallery, image, link, quote, status, video, <code>your-custom-post-type-goes-here</code>
     */

    This should make the template available to those custom post types. Of course you would have to copy the page-templates folder into your child theme (at least I hope you’re using a child theme) then do that.

    I hope this helps. Please let me know.


    #77182

    If I have to work you do too!..lol

    Yep, using a child theme and it added in the page template attributes 🙂

    Now if  I could only get the page options to display that would be some magical stuff happening right there!..lol

    Not to stress you out even more…lol So, there is no way of making these auto-magically appear?

    #77575

    Thomas
    Founder/Lead Dev

    No I don’t wanna work on the weekends…lol and you can’t make me….lol…OK well yes you can but that’s beside the point….lol.

    Do you mean have the Post/Page Options Metabox appear for the custom post types?


    #77805

    Thomas
    Founder/Lead Dev

    OK well my friend I have found a solution to the problem at hand 😉

    I have already added this to the next version of TotalPress and TP Primo. If you like you can edit two files and add a tiny bit of code.

    So go into wp-content-themes/totalpress/assets/totalpress-metaboxes.php. Once you have it open search for thise $prefix = 'totalpress_'; there should be three instances of this.

    OK, so right after that snippet of code, add this:

    $post_types = get_post_types();

    Then look for this: 'post_types' => array('post','page'), (again three instances), and change it to this: 'post_types' => $post_types,.

    This will take care of TotalPress, so let’s move onto TP Primo. Go into wp-content/plugins/tp-primp/assets/metaboxes/tp-primo-metaboxes.php.

    At the very top you will see this function tp_primo_register_meta_boxes( $meta_boxes ) {

    just after that add the following:

    $post_types = get_post_types();

    So it should look like this:

    function tp_primo_register_meta_boxes( $meta_boxes ) {
      $post_types = get_post_types();

    Then look for the following:

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

    and change it to this:

    'post_types' => $post_types,

    Click save and now the metaboxes should be visable for any custom post type.

    Hope this helps. Please let me know how it goes.


    #78785

    Thanks Thomas! Worked like a champ!… Glad this will be in the next update 🙂

    Maybe you could find a solution to getting the page templates to show up auto-magically too for the custom post types?

     

    Thank again!

    #80224

    Thomas
    Founder/Lead Dev

    Hi Donny,

    Good glad it worked for yah and yep thats what I have been trying to do but unfortunately, I haven’t found anything…booo!

    But I will continue on…lol.


Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.