WordPress.org

Ready to get started?Download WordPress

Forums

Related
[resolved] Conflict with SEO All In One Pack (8 posts)

  1. Hube2
    Member
    Posted 1 year ago #

    There is a conflict between this plugin and the SEO All in One Pack, I have posted the problem there, but I am also cross posting here to see if anyone that uses this has a fix for the problem.

    Here's the other post: http://wordpress.org/support/topic/plugin-all-in-one-seo-pack-data-disappears-on-pagepost-edit?replies=5#post-3138931

    The details:

    These are the effects of the interference when this plugin in activated (in order of appearance on the admin page/post page)

    1) Revisions list is truncated to 7 oldest (not even the most recent, but the oldest revisions)
    2) Current Title, Description and Keywords do not appear in fields of All in One SEO Pack area
    3) Title Attribute field completely missing from the All in One SEO Pack area
    4) Menu Label field completely missing from the All in One SEO Pack area

    http://wordpress.org/extend/plugins/related/

  2. fmgguy
    Member
    Posted 1 year ago #

    Awesome plugin, but I'm having similar issues with Yoast's WordPress SEO plugin. When Related is active, it wipes out all the Title, Keyword, and Meta info for every page/post, and replaces it with info from the last page saved. Really sucks, because this is a really cool plugin, and I really would like to use it.

  3. Hube2
    Member
    Posted 1 year ago #

    You can see the explanation of why this plugin is causing the problem in the thread I posted in the seoaiop support. http://wordpress.org/support/topic/plugin-all-in-one-seo-pack-data-disappears-on-pagepost-edit?replies=5#post-3138931

    Has to do with altering the global post id.

    I rewrote the function that displays the related meta field on the post page. the important bit is after the query, rather that use the_post(), which overwrites the global post id I just loop through the results returned by the query.

    // Creates the output on the post screen
    public function displayMetaBox() {

    global $post;
    $post_id = $post->ID;

    // Get related posts if existing
    $related = get_post_meta($post_id, 'related_posts', true);

    if (!empty($related)) {
    echo '<div id="related-posts">';
    foreach($related as $r) {
    $p = get_post($r);
    ?>
    <div class="related-post" id="related-post-<?php echo $r; ?>">
    <input type="hidden" name="related-posts[]" value="<?php echo $r; ?>">
    <span class="related-post-title"><?php echo $p->post_title; ?> (<?php echo ucfirst(get_post_type($p->ID)); ?>)</span>
    Delete
    </div>
    <?php
    } // end foreach post
    echo '</div>';
    } // end if !empty

    $query = array(
    'nopaging' => true,
    'post__not_in' => array($post_id),
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'post_type' => 'any',
    'orderby' => 'title',
    'order' => 'ASC'
    );

    $p = new WP_Query($query);

    $count = count($p->posts);
    if ($count > 0) {
    ?>
    <p>
    <select id="related-posts-select" name="related-posts-select">
    <option value="0">Select</option>
    <?php
    foreach ($p->posts as $thePost) {
    ?>
    <option value="<?php
    echo $thePost->ID; ?>"><?php echo
    $thePost->post_title.' ('.ucfirst(get_post_type($thePost->ID)).')'; ?></option>
    <?php
    }
    ?>
    </select>
    </p>
    <?php
    } // end if count
    wp_reset_query();
    wp_reset_postdata();
    }

  4. fmgguy
    Member
    Posted 1 year ago #

    Thanks much Hube2. I appreciate the help!

  5. photoscope
    Member
    Posted 1 year ago #

    There is a little bug in this code (you can't add related post on a post with none related post).
    You must put out the div "related-posts" of the brace.

    if (!empty($related)) {
    echo '<div id="related-posts">';
    ...
    echo '</div>';
    }

    =>

    echo '<div id="related-posts">';
    if (!empty($related)) {
    ...
    }
    echo '</div>';

  6. new_B
    Member
    Posted 1 year ago #

    Thanks. I discovered that this plugin was the cause of a lot of headaches with another plugin due to it changing the global $post. Can this be incorporated a future release of this plugin as I would consider it a bug.

    (It hasn't been updated in a while--will it be maintained?)

    Thanks.

  7. meadows.pete
    Member
    Posted 11 months ago #

    hey guys - I'm a novice and I'm having trouble understanding how to edit the code posted by Hube2 with the fix posted by photoscope - can someone help me out?! Pretty please? :D

  8. meadows.pete
    Member
    Posted 11 months ago #

    Never mind! For anyone else...

    '// Creates the output on the post screen
    public function displayMetaBox() {

    global $post;
    $post_id = $post->ID;

    // Get related posts if existing
    $related = get_post_meta($post_id, 'related_posts', true);

    echo '<div id="related-posts">';
    if (!empty($related)) {
    foreach($related as $r) {
    $p = get_post($r);
    ?>
    <div class="related-post" id="related-post-<?php echo $r; ?>">
    <input type="hidden" name="related-posts[]" value="<?php echo $r; ?>">
    <span class="related-post-title"><?php echo $p->post_title; ?> (<?php echo ucfirst(get_post_type($p->ID)); ?>)</span>
    Delete
    </div>
    <?php
    } // end foreach post

    } // end if !empty
    echo '</div>';
    $query = array(
    'nopaging' => true,
    'post__not_in' => array($post_id),
    'post_status' => 'publish',
    'posts_per_page' => -1,
    'post_type' => 'any',
    'orderby' => 'title',
    'order' => 'ASC'
    );

    $p = new WP_Query($query);

    $count = count($p->posts);
    if ($count > 0) {
    ?>
    <p>
    <select id="related-posts-select" name="related-posts-select">
    <option value="0">Select</option>
    <?php
    foreach ($p->posts as $thePost) {
    ?>
    <option value="<?php
    echo $thePost->ID; ?>"><?php echo
    $thePost->post_title.' ('.ucfirst(get_post_type($thePost->ID)).')'; ?></option>
    <?php
    }
    ?>
    </select>
    </p>
    <?php
    } // end if count
    wp_reset_query();
    wp_reset_postdata();
    }'

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.