Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Welp, my PM didn’t like my solution either, but his loss is your gain because I took another look at this issue ??

    Instead of getting the lowcode from my “default content” Pattern by-hand… I just do it programmatically by Post ID of my Pattern then return that. Works a mint. I feel both smart and dumb now.

    I hope WP doesn’t do anything to break this functionality, because using Patterns as “pseudo-templates” in this way is super powerful.

    function prefix_filter_book_content($content,$post) {
        if ( $post->post_type === 'book' ) {
            $my_pattern_id = 5055;
            $content_pattern = get_post($my_pattern_id);        
            $content = $content_pattern->post_content;
        }
        return $content;
    }
    add_filter( 'default_content', 'prefix_filter_book_content', 10, 2 );
    • This reply was modified 11 months, 1 week ago by leifer.

    I ran into a similar issue and found this thread looking for the answer myself. I was not able to find a way to inject (and automatically detach) a pattern. I don’t know why, but I remade several Patterns and made sure to unsync them, but none-the-less when added the way you are adding them above they behaved as though they were still synced.

    So, I didn’t find a way to add a Pattern to a Custom Post Type (and detach it).

    However, I did find a similar work around.

    Get your “lowcode” from your Pattern. Manage Patterns -> Find your Pattern -> Export as JSON.

    Take the value of the “content” of that JSON, that’s your “lowcode”.

    Example WordPress “lowcode” for a Pattern with two Paragraph blocks and two Heading blocks.

    <!-- wp:paragraph -->
    <p>My book paragraph.</p>
    <!-- /wp:paragraph -->
            
    <!-- wp:heading {"level":4} -->
    <h4 class="wp-block-heading">Book Heading</h4>
    <!-- /wp:heading -->
    
    <!-- wp:paragraph -->
    <p>Another Book paragraph</p>
    <!-- /wp:paragraph -->
            
    <!-- wp:heading {"level":4} -->
    <h4 class="wp-block-heading">Another Heading</h4>
    <!-- /wp:heading -->

    In my case, I had to do some hand-editing to remove newline characters and such, but eventually got ‘clean’ lowcode that I could then use to inject into the “content” of the post type template.

    function prefix_filter_book_content( $content, $post ) {
        if ( $post->post_type === 'book' ) {
         $content ='<!-- wp:paragraph -->
                    <p>My book paragraph.</p>
                    <!-- /wp:paragraph -->
            
                    <!-- wp:heading {"level":4} -->
                    <h4 class="wp-block-heading">Book Heading</h4>
                    <!-- /wp:heading -->
    
                    <!-- wp:paragraph -->
                    <p>Another Book paragraph</p>
                    <!-- /wp:paragraph -->
            
                   <!-- wp:heading {"level":4} -->
                   <h4 class="wp-block-heading">Another Heading</h4>
                   <!-- /wp:heading -->';
    
        }
        return $content;
    }
    add_filter( 'default_content', 'prefix_filter_book_content', 10, 2 );
    
    

    And, though the setup is a bit “hacky” the end result works. The end-user, when they create a new “Book” custom post type, they will get the “Default” Blocks added to their Editor. But since they are added as Blocks, and not as a Pattern they are treated as page / post content and saved normally without needing to detach anything.

    Thank you for listening to my TED talk.

    leifer

    (@leifer)

    Might be a little too old to help @melissagw, but it looks like the author has pretty much abandoned this plug-in and I recently ran into the same problem.

    The drop-down style Archive Widget can be made functional by doing the following.

    Open the news-manager/js/front-widget.js file.

    Immediately after the jquery document ready statement, so starting on line 2, add the following:

    $(document).on(‘change’, ‘.widget_news_manager_archive_widget select’, function() {
    window.location.href = $(this).val();
    });

    There is a lot more that could be done here… but that will add simple redirecting functionality back in.

Viewing 3 replies - 1 through 3 (of 3 total)