Next/Previous Post Link Plus (Ambrosite) Plug In making post disappear

  • raindance

    #1682

    Hi-

    I thought I’d start a new thread on this.

    I’ve activated the Ambrosite Next/Previous Post Link Plus plug in.

    The instructions are to insert this code on your single.php page

    (as one variation of options, but which is offered as one complete sample) from this page:

    http://www.ambrosite.com/plugins/next-previous-post-link-plus-for-wordpress

    <?php previous_post_link_plus( array(
    'order_by' => 'post_title',
    'loop' => true,
    'max_length' => 30,
    'tooltip' => 'Previous post',
    'in_same_cat' => true,
    'ex_posts' => '5, 12'
    ) );?> |
    <?php next_post_link_plus( array(
    'order_by' => 'post_title',
    'loop' => true,
    'max_length' => 30,
    'tooltip' => 'Next post',
    'in_same_cat' => true,
    'ex_posts' => '5, 12'
    ) );?>

    So, I have a child theme set up. I tried it on both a new

    single.php

    and

    loop-single.php in the child theme folder.

    ON the single.php folder it makes only the new links show up on an otherwise blank page.

    On the loop-single.php file in the child folder, it makes the links show up but the post disappear. So I’m closer with this but the post content itself is gone and the page looks like its missing some elements below the link.

    My page is here:

    http://juicytravels.com/the-ten-best-airline-experiences-now-4/

    The idea is for it to be a series of ten pages (posts) linked together with sequential navigation.

    I don’t love the plugins that help you break up a long post with <!–nexttag–> as they don’t work as well for SEO from what I understand. I think I’d prefer separate pages/posts and link them together unless I’m wrong about that. But even using something like the plug in Multi Page Toolkit, the pages loose seo friendliness.

    Any help much appreciated…I’ve been stuck on this for days now.

    Any ideas? Anyone know the Ambrosite plug in and why my posts are disappearing?

    Thanks in advance.

    Mod

    Kenneth John Odle

    #16804

    Well, even with child theme, you really shouldn’t alter the loop.php or loop-single.php files, because when the theme is updated, you won’t have any new features available. See the end of this post. It is much better to do this with action hooks, such as the graphene_before_post_content action hook.

    (SEO – don’t get me started on that. I’ve seen people do all sorts of crazy stuff in the name of SEO and there’s no guarantee that any of it works. But that’s the subject of another post. Good content + patience = lots of followers & backlinks.)

    Nathan Rice has a good explanation of how to use action hooks here. There are a couple of examples floating around on this forum. I’ll tag them “action hooks” so they’re easy to find.

    Ken

    raindance

    #16805

    The Ambrosite Next/Plus plug in wants you to replace things in the single.php file, but that just calls the loop.php file, and the relevant part there looks like

    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class="post-nav clearfix">
    <p id="previous"><?php previous_post_link(); ?></p>
    <p id="next-post"><?php next_post_link(); ?></p>
    <?php do_action('graphene_post_nav'); ?>
    </div>
    <?php endif; ?>

    But I don’t know if I should replace any of that?

    Jon Lynch

    #16806

    Ok here goes, my post on the other thread suggested copying loop.php, the easiest way. I actually use action hooks. To add a new navigation section and then use css to hide the default one.

    The php code needs to be added to functions.php (create one in your child theme directory if you don’t have one already.

    <?php
    add_action ('graphene_post_nav', 'my_post_nav');
    function my_post_nav(){ ?>
    <p id="previous-new"><?php previous_post_link('&laquo; %link', '%title', TRUE); ?></p>
    <p id="next-post-new"><?php next_post_link('%link &raquo;', '%title', TRUE); ?></p>
    <? }

    You now need to hide the default links using CSS and style the two new ones using:

    #previous-new, #next-post-new { copy css from default links here }
    #previous, #next-post {display: none;}

    You could of course add your ambrosite code to the function I have put above.

    Hope this helps

    Jon

    raindance

    #16807

    Oh I missed the loop.php suggestion before, thanks.

    I’m not sure I’m following.

    You’re saying put that first block of code on the child theme functions.php, yup got that.

    But the action hooks (need to read up on it) but the part I got lost on here is the second code block…so the “add_action” is the action hook?

    “You now need to hide the default links using CSS and style the two new ones using:”

    Are you saying that

    #previous-new, #next-post-new { copy css from default links here }

    #previous, #next-post {display: none;}

    Will make the default nav links hidden, but the Ambrosite ones visible?

    Is this how I can move them say to the far right?

    Does this mean I need to change how I have it now? Here is what I have now:

    In the loop.php file I changed lines 29 and 30

    <p id=”previous”><?php previous_post_link(); ?></p>
    <p id=”next-post”><?php next_post_link(); ?></p>
    [code]
    to
    [code]
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    [code]

    I posted this after the header line on single.php

    [code]
    get_header(); ?>

    then I pasted:

    <?php previous_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Previous page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?> |
    <?php next_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Next page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?>
    [code]

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.
    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉
    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    [code]
    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    <p id=”previous”><?php previous_post_link(); ?></p>

    <p id=”next-post”><?php next_post_link(); ?></p>

    to
    [code]
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    [code]

    I posted this after the header line on single.php

    [code]
    get_header(); ?>

    then I pasted:

    <?php previous_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Previous page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?> |
    <?php next_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Next page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?>
    [code]

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.
    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉
    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    [code]
    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    to

    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    [code]

    I posted this after the header line on single.php

    [code]
    get_header(); ?>

    then I pasted:

    <?php previous_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Previous page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?> |
    <?php next_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Next page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?>
    [code]

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.
    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉
    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    [code]
    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    <p id=”previous”><?php previous_post_link_plus(); ?></p>

    <p id=”next-post”><?php next_post_link_plus(); ?></p>

    I posted this after the header line on single.php

    [code]
    get_header(); ?>

    then I pasted:

    <?php previous_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Previous page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?> |
    <?php next_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Next page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?>
    [code]

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.
    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉
    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    [code]
    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    I posted this after the header line on single.php

    get_header(); ?>

    then I pasted:

    <?php previous_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Previous page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?> |
    <?php next_post_link_plus( array(
    ‘order_by’ => ‘menu_order’,
    ‘loop’ => true,
    ‘max_length’ => 0,
    ‘tooltip’ => ‘Next page’,
    ‘in_same_cat’ => true,
    ‘ex_cats’ => ’12’
    ) );?>
    [code]

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.
    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉
    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    [code]
    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    get_header(); ?>

    then I pasted:

    <?php previous_post_link_plus( array(

    ‘order_by’ => ‘menu_order’,

    ‘loop’ => true,

    ‘max_length’ => 0,

    ‘tooltip’ => ‘Previous page’,

    ‘in_same_cat’ => true,

    ‘ex_cats’ => ’12’

    ) );?> |

    <?php next_post_link_plus( array(

    ‘order_by’ => ‘menu_order’,

    ‘loop’ => true,

    ‘max_length’ => 0,

    ‘tooltip’ => ‘Next page’,

    ‘in_same_cat’ => true,

    ‘ex_cats’ => ’12’

    ) );?>

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.
    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉
    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    [code]
    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    So…it’s showing up and working but yes, I’m worried about when the theme gets updated.

    And, I’m not sure I’m connecting the dots between what you said with adding the action hook and the css change.

    Can you look at what I did and perhaps elaborate on if I need to do it differently…I don’t see post_link_plus in that functions code so I’m confused where/how it knows to use that plug in?

    Sorry for the confusion 😉

    And thanks for the help!

    The other thing I want to do is put those links further down in the body of the post but when I moved the code

    <?php /* Posts navigation for single post pages, but not for Page post */ ?>
    <?php if ( is_single() && ! is_page() ) : ?>
    <div class=”post-nav clearfix”>
    <p id=”previous”><?php previous_post_link_plus(); ?></p>
    <p id=”next-post”><?php next_post_link_plus(); ?></p>
    <?php do_action(‘graphene_post_nav’); ?>
    </div>
    <?php endif; ?>
    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    <?php /* Posts navigation for single post pages, but not for Page post */ ?>

    <?php if ( is_single() && ! is_page() ) : ?>

    <div class=”post-nav clearfix”>

    <p id=”previous”><?php previous_post_link_plus(); ?></p>

    <p id=”next-post”><?php next_post_link_plus(); ?></p>

    <?php do_action(‘graphene_post_nav’); ?>

    </div>

    <?php endif; ?>

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    [code]

    To down below the title or above the content, it didn’t move..I suppose because in single.php it’s right after the header? How can I rearrange things so that it’s below the title line and to the right? I want it to be more integrated with the post itself so it’s easier and more obvious to the reader to keep moving through the “pages” of the article.

    raindance

    #16808

    http://juicytravels.com/the-ten-best-first-class-airline-experiences-now/

    I mean that I want to have the links for example at the bottom of the content but IN the white blog post part, or, under the


    which is under the article title to the far right.

    Thanks again…

    Jon Lynch

    #16809

    Sorry I had taken the code from my functions.php, which probably confused you.

    There are a variety of options of how to complete this:

    – Edit loop.php, Advantage – simple, Disadvantage – overwritten when Graphen is updated

    – Copy loop.php, then edit – Advantage keep changes when upgrading, Disadvantage never get the benefits of new features in upgrades

    – Use Action Hooks, Advantage can upgrade and get benefits, easy to move to another hook, drawbacks more complex to implement.

    <?php
    // attaches the function my_post_nav to the hook graphene_post_nav
    add_action ('graphene_post_nav', 'my_post_nav');

    // our function
    function my_post_nav(){

    // this will allow us to use other hooks but still only show on single posts
    if ( is_single() && ! is_page() ) : ?>
    <div id="my-post-nav"> <!-- div to contain your links -->
    <?php previous_post_link_plus( array(
    'order_by' => 'menu_order',
    'loop' => true,
    'max_length' => 0,
    'tooltip' => 'Previous page',
    'in_same_cat' => true,
    'ex_cats' => '12'
    ) );?> |
    <?php next_post_link_plus( array(
    'order_by' => 'menu_order',
    'loop' => true,
    'max_length' => 0,
    'tooltip' => 'Next page',
    'in_same_cat' => true,
    'ex_cats' => '12'
    ) );?>
    </div>
    <?php endif; ?>
    <?php } ?>

    If you place the whole code block into your functions.php you should see your links underneath the default ones.

    If this is working for you then you can experiment with replacing graphene_post_nav with the names of other hooks. A complete list is at http://wiki.khairul-syahir.com/graphene-theme/wiki/Actions_Reference . I would recommend trying graphene_before_post or graphene_before_post_content.

    If all this works you just need to hide the existing links using css and style the new links.

    Hope this helps

    Jon

    Jon Lynch

    #16810

    if you are looking to have the links at the bottom try one of

    graphene_after_post_content
    graphene_post_footer
    graphene_loop_footer

    Instead of graphene_post_nav

    raindance

    #16811

    Thank you so much for the detailed help.

    Ok, I want to do it right the first time so if you’ll bear with me I want to use action hooks. It would be silly to do otherwise.

    I did read through the links Ken sent…very helpful, thanks Ken.

    So are you saying then:

    to remove what I have on loop.php

    remove what I have on single.php

    add the code above only to the functions.php file in my child theme file?

    If so, the code above replaces the need to change lines 29 and 30 on the main loop.php file where you add the _plus?

    And if I don’t want it at the bottom, haven’t played with it yet, but want it after the hr under the title, is there any code you know of for that?

    And when you say instead of graphene_post-nav, you mean in the hook line

    add_action (‘graphene_post_nav’, ‘my_post_nav’);

    ?

    THANK YOU 🙂 I really appreciate it!

    Jon Lynch

    #16812

    Yes to all of the above!

Viewing 10 posts - 1 through 10 (of 28 total)
  • You must be logged in to reply to this topic.
Do NOT follow this link or you will be banned from the site!