WordPress.org

Ready to get started?Download WordPress

Forums

Yet Another Related Posts Plugin (YARPP)
[resolved] White Page when not publish a post (6 posts)

  1. DZVO
    Member
    Posted 1 year ago #

    Hello Mitcho,
    my name is Maik, I use your Plugin on different Blogs.
    But in one Blog I have a problem.

    When I edit a post and I don't publish the new version, then I get a white page for this posting.

    i used your plugin in my plugin :)
    here is the code

    <?php
    /*
    Plugin Name: Google Ads!
    Plugin URI:
    Description: add Google Ads in the Blog posts
    Version: 0.1
    Author: Maik Schindler
    Author URI: http://www.zauberpage.de
    */
    
    add_action('plugins_loaded', 'msGoogleAdsInstall');
    add_filter('the_content', 'msGoogleAds');
    
    function msGoogleAdsInstall()
    {
            global $wpdb;
    
            if(isset($_REQUEST['activate']) && $_REQUEST['activate'] == true){
                    $checkedTable = $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key='_simple_google_ads' LIMIT 1");
                    if(!$checkedTable)
                            $wpdb->query("INSERT INTO $wpdb->postmeta SET meta_key = '_simple_google_ads', meta_value = '1'");
            }elseif(isset($_REQUEST['activate']) && $_REQUEST['action'] == 'deactivate'
                    && isset($_REQUEST['plugin']) && $_REQUEST['plugin'] == 'google-ads/google-ads.php'){
                    $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = '_simple_google_ads'");
            }
    }
    
    function msGoogleAds($content = false)
    {
            global $post;
    
            if(is_single()){
            $ads = '<div class="ads">
                            <script type="text/javascript"><!--
                                    google_ad_client = "pub-8320213041632818";
                                    google_ad_width = 300;
                                    google_ad_height = 250;
                                    google_ad_format = "300x250_as";
                                    google_ad_type = "text";
                                    google_ad_channel = "5398256405";
                                    google_color_border = "FFFFFF";
                                    google_color_bg = "FFFFFF";
                                    google_color_link = "0058AF";
                                    google_color_text = "000000";
                                    google_color_url = "A01A00";
                                    //--></script>
                            <script type="text/javascript"
                              src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
                            </script>
                            ';
                                    if (function_exists('related_entries')){
                                            $ads .= related_entries(array(), $post->ID, false);
                                    }
                            $ads .= '
                            </div>';
            }else{
                    $ads = '';
            }
            $content = str_replace('<!-- google ads -->', $ads, $content);
    
            return $content;
    }
    ?>

    here can you see the plugin in works http://www.xxltravel.de/nachrichten/.../

    Can you help me?
    Do you see what is the problem?

    Maik

    http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/

  2. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    You should look at your server error log which should tell you what the PHP error is. Also, you should turn on errors:

    https://codex.wordpress.org/Debugging_in_WordPress

  3. DZVO
    Member
    Posted 1 year ago #

    Hello mitcho

    here is a php log
    [01-Mar-2013 19:10:10] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 74274 bytes) in /srv/www/vhosts/xxltravel.de/html/nachrichten/wp-includes/functions.php on line 3773

  4. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    Oh, I see. You're using a the_content filter to call YARPP. This is unsupported, because YARPP needs to look a the content of the post to do its computation, and therefore it is going to create an infinite loop.

    I suggest calling the code to display YARPP's result outside of the_content.

  5. DZVO
    Member
    Posted 1 year ago #

    What a pity! Isn't it possible to fix it for the next version? I think that, for SEO optimation reasons it is better, when related links are in the content and not under the content.

    best regards, Maik

  6. mitcho (Michael Yoshitaka Erlewine)
    Member
    Plugin Author

    Posted 1 year ago #

    @DZVO for SEO reasons, it is irrelevant whether the related posts are technically inside the WordPress "content" or not. What matters is how the links are displayed on your site... if they're grouped together with the content, I think search engines will pick it up as part of the content.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic