• Resolved christianlersch

    (@christianlersch)


    Thank you very much for this great Plugin! I use it very much for related Posts!

    Now I use it the first time for Custom Post Types and it not works very well.

    The problem is under “list tuning”. If I choose the custom post type under “Post types to include” or check the checkbox “Limit to same post type” the script in the frontend is running since the “Allowed memory size” is exhausted and PHP gets an error. If I give more memory the problem only will come later. Also caching didn’t bring a solution.

    But If I not specify the related posts content it shows one of the custom post type posts and also two attachments. So he finds it. But if I specify the query only to the custom post type it won’t work.

    Do you have an idea what can I do to make it work?

    Thank you very much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Ajay

    (@ajay)

    @christianlersch

    Few questions:
    1. Please can you show me a screenshot of the settings you have
    2. Which custom post type are you selecting e.g. with a specific plugin?
    3. Does it happen if you select a) both custom post types and Same post type or b) one of these
    4. Does it happen on specific post types where you run into this error?

    Usually this memory exhaustion is if the plugin landed into a circular loop but that is typically not something I would expect

    Thread Starter christianlersch

    (@christianlersch)

    Hi Ajax,

    thanks for the quick response!!!

    1. https://ibb.co/mGhn6Xg

    2. I createt the Custom Post Type with the Plugin “Custom Post Type UI”

    3. It fail with both selections seperate and also if I only choose one of these settings.

    4. In other WordPress installations i not have the problem. There I only use it for posts. This is the first time I use it on Custom post types.

    I get errors like these if the setting like above are set:
    Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 69632 bytes) in /wordpress/wp-includes/formatting.php on line 489

    I think it is a follow up error, because if I give the php more Memory it is on a different point…

    Plugin Author Ajay

    (@ajay)

    @christianlersch

    I have tried replicating on my installs to test these settings with custom post types but it doesn’t throw an issue.

    Could you please reset the settings of the plugin and tell me if it works with the default settings – even if there are non-optimal results.

    Next just change the setting to “Limit to same post type” and save settings and check again.

    I can’t see anything in the code that should be creating an issue. The same post type is the setting that will take precedence over the other settings.

    Thread Starter christianlersch

    (@christianlersch)

    I think I found the Problem! It was not on your side!!! Very sorry!!!!

    I use the Custom Post Type UI Plugin for the Custom Post type. Additional, I use WP-Bakery to make big Content Pages in that CPT.

    I also hack the output of the plugin with this code under function to output my own Stlyle with additional Custom Fields:

    
    function crp_custom_projects( $output, $result, $args ) {
        $projektfortschritt = get_field('projektfortschritt',$result->ID);
        $output = '';
        $output .= '<div class="col-12 projektebox col-md-6 col-lg-4 px-md-2"><div class="card mb-4" >';
        $output .= '<div class="card-img-top"><div class="projektfortschritt">'.gimmeprojektfortschritt($projektfortschritt, "weiss").'</div>';
        $output .= '<a>ID).'">'.get_the_post_thumbnail($result->ID, "projektquadrat").'</a></div>';
        $output .= '<div class="card-body mx-3 mt-3"><h5 class="card-title"><a href="'.get_the_permalink().'">'.get_the_title($result->ID).'</a></h5></div>';
        $output .= '<div class="card-footer mx-3 mb-3"><p class="card-text">'.substr(get_the_excerpt($result->ID), 0, 85).'...</p><div class="buttonbox"><a>ID).'" class="btn btn-primary">Weiterlesen</a></div></div>';
        $output .= '</div></div>';
    
        return $output;
    }
    add_filter( 'crp_title', 'crp_custom_projects', 10, 3 );

    `

    It looks like that: https://ibb.co/5LBKD05

    Now I think the problem was this part of the code “get_the_excerpt()”, because there is no auto generated Excerpt. And the Content is full of Shortcodes because of the WP-Bakery. I think that the get_the_excerpt() open the Content and try to generate the Excerpt but it is to much.

    I am very sorry that I not try more before contact you!

    Thanks & Cheers
    Chris

    Plugin Author Ajay

    (@ajay)

    Thank you for confirming. You could use crp_excerpt instead: https://github.com/WebberZone/contextual-related-posts/blob/master/includes/tools.php#L25

    Thread Starter christianlersch

    (@christianlersch)

    ok! THX!!!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Problem with Custom Post Types’ is closed to new replies.