previous / next button for portfolio by category

pending (9 posts) (3 voices)

  1. sandjanice
    Member

    I wanted to know if there was a way to have previous and next buttons at the bottom of a portfolio. The website is for dogs and cats at our animal shelter. The portfolios are divided up by category [for example, available dogs, recently adopted dogs, etc.]. Each dog/cat has an individual portfolio. My question is, when you view the individual portfolio, I would like for the name of the next/previous dog to be linked from the bottom of the page. Since there are a lot of updates to the site, there isn't time to manually place the url, so I wondered if there is a way to do this dynamically.

    The website is http://athenspets.net

    Specifically, I would like for this to appear on the individual 'available dogs' and 'available cats'.

    Posted 4 years ago #
  2. Elliott
    Support

    Hello sandjanice,

    You can use this function, http://codex.wordpress.org/Function_Reference/next_post_link, to display a next link.

    And you can use this hook,

    add_action( 'mysite_singular-portfolio_after_entry', 'mysite_portfolio_next' );

    To add it at the bottom of your portfolio posts.

    So for example you would add that around line 150 in your /wp-content/themes/[your_theme]/framework.php file and then add this to the bottom,

    function mysite_portfolio_next() {
         echo next_post_link();
    }
    Posted 4 years ago #
  3. sandjanice
    Member

    Thanks Elliot.
    Let me make sure I understand where I need to add the code:

    Add this hook to the bottom of hook-actions.php for the theme
    add_action( 'mysite_singular-portfolio_after_entry', 'mysite_portfolio_next' );

    Add this to loop.php for the theme [if yes, where should it be placed?]
    <?php next_post_link('%link', 'Next post in category', TRUE, '13'); ?>

    Add this to framework.php
    function mysite_portfolio_next() {
    echo next_post_link();
    }

    Also, can I add a previous link as well?
    Appreciate your quick response to my question.

    Posted 4 years ago #
  4. Elliott
    Support

    You add this around line 150 in framework.php,

    add_action( 'mysite_singular-portfolio_after_entry', 'mysite_portfolio_next' );

    And at the bottom of the same file add this,

    function mysite_portfolio_next() {
    echo next_post_link();
    }
    Posted 4 years ago #
  5. reggiethecat
    Member

    This works quite nicely... I've modified the function to show previous as well with a bit of formatting...
    function mysite_portfolio_next() {
    echo previous_post_link();
    echo '  ||  ';
    echo next_post_link();
    }

    What I am having trouble with is keeping the navigation in the same category. I tried:
    echo previous_post_link('%link','%title',TRUE);
    for example... but it came up blank.

    Can you help?
    Thanks!

    Posted 4 years ago #
  6. Elliott
    Support

    Send us a link to where it's showing.

    Posted 4 years ago #
  7. reggiethecat
    Member

    Here is one of the portfolio pages. http://jsblogtest.4030.com/portfolio/aunt-fannies-kitchen/gallery/helena/

    In framework.php, I've set up the Previous to be
    echo previous_post_link('%link','%title',TRUE);
    leaving the 'next' with the defaults.

    Posted 4 years ago #
  8. Elliott
    Support

    Do you have a category selected in the portfolio shortcode?

    Posted 4 years ago #
  9. reggiethecat
    Member

    Yes. For the page that I sent, it is "Helena". Might this have something to do with setting the permalink structure to postname?

    Posted 4 years ago #

Reply

You must log in to post.

Construct WordPress Theme
Construct wordpress theme
Myriad WordPress Theme
Myriad wordpress theme
Method WordPress Theme
Method wordpress theme
Fusion WordPress Theme
Fusion wordpress theme
Elegance WordPress Theme
Elegance wordpress theme
Echelon WordPress Theme
Echelon wordpress theme
Dejavu WordPress Theme
Dejavu wordpress theme
Modular WordPress Theme
Modular wordpress theme