Forum Replies Created

Viewing 15 replies - 61 through 75 (of 89 total)
  • Thread Starter trixienolix

    (@trixienolix)

    ce_bradm: if you’re on nuclear or biomass page (both of which are subpages of what we do – id 131) then you should see the content for that page, underneath that should be 2 relevant blog posts and then 2 relevant resources.

    alchymyth: I will have a go and report back

    I’m currently trying out a version with query_posts and reset…

    Thread Starter trixienolix

    (@trixienolix)

    OK, here’s the original code that was messing up my sidebar tree and post_parent:

    messes up sidebar conditionals
    There are multiple loops and conditional statements.
    If you could let me know what’s wrong with it i’d be really greateful. My knowledge of multiple loops is obviously lacking.

    Thread Starter trixienolix

    (@trixienolix)

    just seen your comment – will put the page back together and put it up
    thanks you so much

    Thread Starter trixienolix

    (@trixienolix)

    can you advise me on which methos of adding multiple loops is best? There are many different examples out there, some using query_posts with a reset and others using wp_query. What are the advantages / differences of each method?

    Thread Starter trixienolix

    (@trixienolix)

    i’ve tried everything! I’ve used query_posts with a reset and now I’m using new WP_Query…
    whenever i put a secondary loop onto my page, the sidebar loses the ability to check the tree or parent status…
    I’m going to keep trying as it must just be something daft that I’m doing.
    aaagggghhh!!

    Thread Starter trixienolix

    (@trixienolix)

    ok, it’s definitely something to do with teh code on my page.php – if i just have 1 loop it works fine (sidebar shows correct tree and parent info) but when I put my loops back in it goes wrong.

    Could you help with my conditional statements and multiple loops??

    Thread Starter trixienolix

    (@trixienolix)

    thanks for your help. Reall appreciated.

    I added your print_r code to my page (for anyone else that needs it, the actual code you need to put in the page is this: <?php print_r($post); ?>

    On my subpage i get this:

    stdClass Object ( [ID] => 146 [post_author] => 1 [post_date] => 2011-07-26 12:44:02 [post_date_gmt] => 2011-07-26 12:44:02 [post_content] => CONTENT REMOVED FOR THIS FORUM [post_title] => Nuclear Energy [post_excerpt] => [post_status] => publish [comment_status] => open [ping_status] => open [post_password] => [post_name] => nuclear-energy [to_ping] => [pinged] => [post_modified] => 2011-07-26 14:55:32 [post_modified_gmt] => 2011-07-26 14:55:32 [post_content_filtered] => [post_parent] => 131 [guid] => https://XXX/?page_id=146 [menu_order] => 0 [post_type] => page [post_mime_type] => [comment_count] => 0 [ancestors] => Array ( [0] => 131 ) [filter] => raw )

    I then added snippet 4 to my functions .php and altered my sidebar code to this (i added some code to test the tree code as well – see below):

    <?php
    	echo "<p>is page 'what-we-do' = " . is_page( 'what-we-do' ) . "</p>";
    	echo "<p>post parent = " . $post->post_parent . "</p>";
    	echo "<p>is tree = " . is_tree( '131' ) . "</p>";
    ?>
    
    <?php
    
    	if ( is_tree( '131' ) )
    	{
    		if ( ! dynamic_sidebar('What We Do Sidebar') ) : endif;
    	}
    	else
    	{
    		if ( ! dynamic_sidebar('Main Sidebar') ) : endif;
    	}
    ?>

    When I’m on my page 131 I get the correct sidebar and the following info about it:

    is page ‘what-we-do’ = 1
    post parent = 0
    is tree = 1

    But when I’m on my subpage of 131 (the nuclear energy page listed above I get this:

    is page ‘what-we-do’ =
    post parent = 0
    is tree =

    even thought it is a subpage of page 131!

    SO now I’m wondering if one of my multiple loops on the page is doing something odd to my conditional statements? I struggle with multiple loops so there’s a chance i’ve not done it right. Would that have this effect?

    thank you in advance

    Thread Starter trixienolix

    (@trixienolix)

    Thank you for looking.
    I pasted your code in to my sidebar.php above my (now cleaned up!) code and this is what I get:

    is page ‘what-we-do’ =
    post parent = 0

    this was on a subpage of “what-we-do”.

    On the actual what-we-do page i get this:
    is page ‘what-we-do’ = 1
    post parent = 0

    and the correct sidebar shows up.

    So it’s not picking up my page parent?

    If i look at my rendered source code, my body tag should give me some more clues:
    <body class="page page-id-146 page-child parent-pageid-131 page-template-default logged-in admin-bar single-author singular">
    which looks like it is seeing the parent??

    Thread Starter trixienolix

    (@trixienolix)

    sorry, code not in backticks again:

    <?php if ( is_page( 'what-we-do' ) || '131' == $post->post_parent ) { ?>
    <?php if ( ! dynamic_sidebar('What We Do Sidebar') ) : ?><?php endif; ?>
    <?php } else { ?>
    <?php if ( ! dynamic_sidebar('Main Sidebar') ) : ?><?php endif; ?>
    <?php } ?>
    Thread Starter trixienolix

    (@trixienolix)

    hi it’s more the security issue that I need to ensure is totally water tight. Do you know anything about setting up secure uploads / downloads with wp?

    Thread Starter trixienolix

    (@trixienolix)

    hmm, i’ve had a quick scan but these just do what I’ve already done i.e. enable me to have different sidebars on different pages depending on the id, parent page or category. I can’t see that any of them enable me to have different sidebars based on the referral page… i’ll double check.

    teknohippy – you’re right that if you don’t add a custom field for a menu then it defaults back to the one assigned to that location in the Appearance -> Menus. But this is what i *don’t* want to happen. I want it to default to no menu at all, including no html code.

    I found the answer, in case anyone else want sto know… just use the fallback_cb code but with no value:

    'fallback_cb' => ''

    So my sidebar.php file looks like this now:

    <!-- custom fields need to be inside the loop -->
    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    <?php wp_nav_menu( array( 'fallback_cb' => '', 'theme_location' => 'sub-navigation', 'menu' => get_post_meta( $post->ID, 'MenuName', true) ) ); ?>
    
    content here as well
    <?php endwhile; ?>

    ok, just tested it and you don’t need to add the names into functions.php, so it’s a good solution. Thanks!

    One question – if i don’t define a custom MenuName in a page or post then I don’t want it to show any menu. Can you tell me how to do this?

    teknohippy I like your approach but you still have to set up the name of the different custom menus on the functions.php page don’t you? Which is fine if you’re a techy person, but if you’re handing the wp site over to a non-techy client then it’s not ideal either.

    I’ve been trying to work out the ideal front-end user solution to this. I wonder whether widgetising the theme in the place you want the menu to go, then make the menus in the admin, then add these menus to the widgetised area using the menu widget. Then you’d need to get the widget logic plugin to do the conditional statements in a “friendly” non-techy way.

    What does anyone think??

    I’m looking through newsletter plugins now too and have looked at:
    meenews, vertical response, Newsletter and g-lock double opt in.
    I’m thinking so far that the g-lock one is the best for me.. i don’t want to have to use g-lock but you don’t have to and it lets you configure lots of settings. it also comes as a widget which is what I want and most importantly it allows you to export emails.

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