Forum Replies Created

Viewing 15 replies - 61 through 75 (of 153 total)
  • Thread Starter chavo

    (@chavo)

    Ok. Assuming that “latest” category ID is = 1 and that you ONLY have the mentioned categories, please try with the code as follows.

    In footer.php:

    <?php
    $this_category = get_category($cat);
    if (is_category('latest')) {
    $_SESSION['history'] =  "visitorComesFromLatest";
    }
    ?>
    <?php wp_footer(); ?>

    In single.php:

    <?php
    if(isset($_SESSION['history'])){
    if ($_SESSION['history'] == "visitorComesFromLatest") {
    previous_post_link ('<span class="prev">%link</span>','PREV', false);
    next_post_link ('<span class="next">%link</span>','NEXT', false);
    }
    } else {
    previous_post_link ('<span class="prev">%link</span>','PREV', true);
    next_post_link ('<span class="next">%link</span>','NEXT', true);
    }
    ?>

    Thread Starter chavo

    (@chavo)

    Yes. But, just to be clear:

    In this line
    } else if (is_category('portfolio')) {
    the word “portfolio” refers to category slug/name.

    In this line
    $_SESSION['history'] = "portfolio";
    the word “portfolio” refers to the variable name assigned to history session.

    Thread Starter chavo

    (@chavo)

    php tags is correct.

    I’m assuming you know about php code. Do you?

    Thread Starter chavo

    (@chavo)

    I always hide the bar (in frontpage) via functions.php but that’s not the case.

    Does your code in footer.php looks similar to this?

    <?php
    $this_category = get_category($cat);
    if (is_home() || is_front_page()) {
    $_SESSION['history'] =  "home";
    } else if (is_category('portfolio')) {
    $_SESSION['history'] =  "portfolio";
    } else if ($this_category->category_parent == 1) {
    $_SESSION['history'] =  "portfolio subcategory";
    }
    ?>
    <?php wp_footer(); ?>

    Note: you have to change “is_category(‘portfolio’)” with your category slug and $this_category->category_parent == 1 with the ID of that category (in my case “portfolio” category ID = 1).

    Thread Starter chavo

    (@chavo)

    Tell me what’s the problem.

    Thread Starter chavo

    (@chavo)

    No problem, you’re welcome!

    Thread Starter chavo

    (@chavo)

    Mmmm… How are you managin your post? When you publish a post you check both parent and child category or only the child category?

    In my example the “portfolio” session history have this name because I want to know if visitor comes from “portfolio” category. In your case, you can replace it by your own category.

    In my case, this parameter ‘ex_cats’ => ‘9’ excludes the category “news” so I cant navigate through post in any portfolio posts (asigned to a portfolio subcategory).

    In the default linking navigation the parameter TRUE tells navigation that you want to navigate between posts in same category.

    So, to be clear:

    If I came from home or portfolio (I display posts that belongs the portfolio subcategories in home page) > Allow posts navigation between posts in ANY portfolio subcategory.

    If I came from a portfolio subcategory, navigate through posts in same subcategory.
    edit: I notice that when I translated my code I left a piece of spanish code, so in your theme code in footer you have to replace
    } else if ($_SESSION[‘history’] == “subcategoria portfolio”) {
    with
    } else if ($_SESSION[‘history’] == “portfolio subcategory”) {

    By “enable history” I want to mean that you have to declare the session. In my case I call it “history”.

    I hope to be clearer.

    ps: once again, sorry for my “tarzan english”.

    Thread Starter chavo

    (@chavo)

    Ok. The blank problem maybe is because of a bad closed code. Check if nothing is missing. Try one step at once to check in wich step you get the blank page. Perhaps I forget to close a conditional statement.

    Thread Starter chavo

    (@chavo)

    Hi. At this point (7 months later) I don’t remember really well but I think that I did it. Finally I decided to use another way to show my posts so I didn’t need this function anymore.

    First, download and install this plugin:
    Ambrosite Next/Previous Post Link Plus

    Second, you need to know where you are coming from (home / category archive). To get this goal I decided to use sessions.

    1) At functions.php you need to enable sessions to work. Put this code at the beggining of the file:

    /**
     *    init_sessions()
     *
     *    @uses session_id()
     *    @uses session_start()
     */
    function init_sessions() {
        if (!session_id()) {
            session_start();
        }
    }
    add_action('init', 'init_sessions');

    2) Enable “history” (where you are coming from?). Put this code in footer.php before <?php wp_footer(); ?>

    $this_category = get_category($cat) // get category ID;
    if (is_home()) {
    $_SESSION['history'] =  "home";
    } else if (is_category('portfolio')) {
    $_SESSION['history'] =  "portfolio";
    } else if ($this_category->category_parent == 1) { // for "portfolio" child categories
    $_SESSION['history'] =  "portfolio subcategory";
    }

    Now you have sessions working, you need to use conditional tags in single.php.

    if(isset($_SESSION['history'])){ // if "history" session exists
    if ($_SESSION['history'] == "home" || $_SESSION['history'] == "portfolio") { // if you come from home or portfolio, use prev/next links plus code
    previous_post_link_plus(array('format' => '<span class="prev">%link</span>', 'link' => '« PREV', 'ex_cats' => '9'));
    next_post_link_plus(array('format' => '<span class="prev">%link</span>', 'link' => 'NEXT »', 'ex_cats' => '9'));
    } else if ($_SESSION['history'] == "subcategoria portfolio") { // if you come from a portfolio subcategory use native wordpress prev / next links
    previous_post_link ('<span class="next">%link</span>','« PREV', TRUE);
    next_post_link ('<span class="prev">%link</span>','NEXT »', TRUE);
    }
    } else { // if "history" doesn't exist use prev/next links plus code (maybe this code is not necessary)
    previous_post_link_plus(array('format' => '<span class="prev">%link</span>', 'link' => '« PREV', 'ex_cats' => '9'));
    next_post_link_plus(array('format' => '<span class="prev">%link</span>', 'link' => 'NEXT »', 'ex_cats' => '9'));
    }

    Well, like I said, I don’t remember really well if this worked ok (I think I get it but I’m not sure). Let me know if this works for you.

    ps: sorry for my english.

    First, I do not see a “Add Audio” button in the visual editor (like shown here: http://wpaudioplayer.com/usage/)

    That’s because the “all in one” button in the WP admin panel for media files.

    Second, when attaching an mp3 from the media library (to a page or to a post) there is no option in the drop down list for selecting “Audio Player”.

    Same problem here! No option to insert shortcode not manually.

    Thread Starter chavo

    (@chavo)

    Tiago, tú me enviaste el email. Estamos hablando en inglés pudiendo hablar tranquilamente en español. Posiblemente el plugin que mencionas hackea el calendario default o genera el propio y permite que se vean los títulos de los posts. No es un problema con Future posts me parece sino con cómo de genera el calendario por default (o quizás me esté faltando algún parámetro).

    Thread Starter chavo

    (@chavo)

    Can you show me a link? In my calendar when I hover my links it doesn’t show anything because It uses the default calendar hacked.

    Thread Starter chavo

    (@chavo)

    “future” status does really exist?

    I use a plugin called “no future posts” to pull future posts.

    Hi, nice function! Is there a way to define the amount of words of the excerpt length for different instances of the template tag?

    Thanks in advance.

    ps: sorry for my english.

    Thread Starter chavo

    (@chavo)

    You are welcome!

Viewing 15 replies - 61 through 75 (of 153 total)