• I am new to wp and php and Im wondering if its possible to take a variable (lets say $myVar) and assign a value to it on one of my archive pages, but make it global so I can access it elsewhere. I have tried a few things that I have found on the internet but they all just broke my archive page (showed absolutely nothing).

    If anyone could help me out the help would be much appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Let’s go the other way around. Instead of technicalities, tell us WHAT do you want to do, what is your final goal? (don’t tell me HOW do you want to do it; that might be the problem that you think you know…)

    Thread Starter armstrong1118

    (@armstrong1118)

    I would like certain pages to declare a variable value so that, possibly through the use of a function, the sidebar can use a menu that relates.

    Are you talking about webpages in general or Pages (and I mean for you to read the linked resources!)

    In your initial post you mentioned “archive pages” – that doesn’t add up with your last statement. In WP you can have monthly or category archives listings (like when clicking on a month or category name). So, what were you thnking about?

    So, now try it again (and don’t mention variables and functions – I don’t know what they are): just describe on what kind of view* what is the desired end result.

    ____________________
    *view = like main page, single post view, cat archive view, monthly archive view, Page… other

    Thread Starter armstrong1118

    (@armstrong1118)

    Alright, sorry for not being real clear on this. Im trying to make a portfolio site to display projects. Right now, you navigate using the sidebar to go through the different categories to the projects (services > web > project 1).

    Thats all fine and dandy, the problem is whenever you go into the singe post view (single.php) I want the sidebar show the rest of the web projects.

    The other thing is that project 1 also classifies as a marketing piece, so I would want to make it so if they acess the project 1 through the marketing category, on the single.php I would like the sidebar to show the rest of the marketing projects.

    (I hope thats better)

    Thats all fine and dandy, the problem is whenever you go into the singe post view (single.php) I want the sidebar show the rest of the web projects.

    This part is relatively easy:
    Conditional_Tags – especially in_category… and call/include a sidebar that has a miniloop to show what you want. Alternatively, a big, big, long sidebar with million conditionals (I, personally, don’t like that)

    Now, for the second part: if I understand it well, you would like to display a different sidebar based on “referrer”, i.e. where the visitor is coming from. I can’t remember any solution for that – which doesn’t mean it is impossible.
    I am curious, too, whether any PHP guru can provide you a solution.

    Otto? Kaf?

    Thread Starter armstrong1118

    (@armstrong1118)

    Yea, since I wasnt able to find anything in my initial searches for referrer that wasnt a stats thing. Thats why my thought was to see if it was possible through variables and such, but if there is a way through a referrer Im sure its much better.

    Thanl you for the help on the first part.

    Thread Starter armstrong1118

    (@armstrong1118)

    Is there anyone who might be able to help me?

    Thread Starter armstrong1118

    (@armstrong1118)

    alright, I figured this out, but its gonna get very messy and I was wondering if anyone had any ideas/suggestions on how to maybe clean it up?

    Right now I have this code in my sidebar.php
    ——————————————–
    <?php
    if (is_single() && $_SERVER[‘HTTP_REFERER’] == “INSERT URL”) {
    wp_list_bookmarks(stuff);
    }
    ?>

    Im really glad that it works, not so pumped about how many different instances im gonna have to put in though…

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘new to wp and php, need help’ is closed to new replies.