Forum Replies Created

Viewing 15 replies - 1 through 15 (of 15 total)
  • Thread Starter wilfswann

    (@wilfswann)

    I changed the function a bit to

    function get_my_pages($id, $key='') {
    	if($key !='') {
    		$parentID = ($id == '') ? '' : '&child_of='.$id;
    		$my_pages = get_pages('meta_key=' . $key . $parentID);
    		$html= '';
                    if(!empty($my_pages)){
    		$html .= '<ul>';
                      foreach ($my_pages as $pagg) {
      	    	  $html .=  '<li class="' . $pagg->meta_value . '"><a href="' . get_page_link($pagg->ID) . '">';
      	    	  $html .=  $pagg->post_title . '</a></li>';
                      }
                   $html .= '</ul>';
                   return $html;
                   }
            }
    }

    So that you don’t need to specify the class of the list, you get a list of all of the pages which is exactly what I was looking for. It seems to work perfectly so I’m a happy bunny, thanks again.

    Thread Starter wilfswann

    (@wilfswann)

    okay I think I worked out how to do that myself by removing a few things from the code. Works exactly how I wanted it to, thanks heaps!

    Thread Starter wilfswann

    (@wilfswann)

    thank you so so much for your help. I know I have already asked too much of you but it is possible to list all the pages with the ‘myclass’ key regardless of the value and then set the value as the class?

    not sure if maybe you can just get rid of the '&meta_value=' . $value . part or if there is something more fundamental to it.

    Thread Starter wilfswann

    (@wilfswann)

    bingo that worked ??

    Thread Starter wilfswann

    (@wilfswann)

    myclass value =print

    is what i get

    Thread Starter wilfswann

    (@wilfswann)

    hmmm still getting nothing, how annoying. does it matter if the pages are a child of another page? also does it matter if there are other custom fields?

    Thread Starter wilfswann

    (@wilfswann)

    still no results, just says

    Array
    (
    )

    Thread Starter wilfswann

    (@wilfswann)

    aha I didn’t see your latest post before I posted but they look the same to me?

    Thread Starter wilfswann

    (@wilfswann)

    thank you again for your help kees.

    I got an array from that second code but none from the first one so I must have done the custom field wrong. Here’s a screenshot of the custom field, where am I going wrong?

    https://img684.imageshack.us/img684/964/screenshot20100617at230n.png

    Thread Starter wilfswann

    (@wilfswann)

    I made that edit but it still came out as

    <div id="nav">
        <div id="topnav">
        	<ul>
              <li class="frontpage page_item page-item-508"><a href="https://wilfswann.co.uk/" title="Home">Home</a></li>
    <li class="work-new page_item page-item-637"><a href="https://wilfswann.co.uk/work-new/" title="Work New">Work New</a></li>
    <li class="sketchbook page_item page-item-11"><a href="https://wilfswann.co.uk/sketchbook/" title="Sketchbook">Sketchbook</a></li>
    
    <li class="friends page_item page-item-80"><a href="https://wilfswann.co.uk/friends/" title="Friends">Friends</a></li>
    <li class="showreel page_item page-item-19"><a href="https://wilfswann.co.uk/showreel/" title="Showreel">Showreel</a></li>
            </ul>
        </div>
        <div id="subnav">
            <ul>
              <li class="work-rsa-stamps page_item page-item-265"><a href="https://wilfswann.co.uk/work/rsa-stamps/" title="Alternative Energy Stamps">Alternative Energy Stamps</a></li>
    <li class="work-corporate-show page_item page-item-262"><a href="https://wilfswann.co.uk/work/corporate-show/" title="Another Corporate Show">Another Corporate Show</a></li>
    
    <li class="work-aymm page_item page-item-38"><a href="https://wilfswann.co.uk/work/aymm/" title="Are You My Mother?">Are You My Mother?</a></li>
    <li class="work-bruges-tozer page_item page-item-77"><a href="https://wilfswann.co.uk/work/bruges-tozer/" title="Bruges Tozer">Bruges Tozer</a></li>
    <li class="work-experiments page_item page-item-209"><a href="https://wilfswann.co.uk/work/experiments/" title="Experiments in Motion">Experiments in Motion</a></li>
    <li class="work-futurism page_item page-item-258 current_page_item"><a href="https://wilfswann.co.uk/work/futurism/" title="Futurism">Futurism</a></li>
    <li class="work-heartstringtheory page_item page-item-260"><a href="https://wilfswann.co.uk/work/heartstringtheory/" title="heartstringtheory">heartstringtheory</a></li>
    <li class="work-heata page_item page-item-132"><a href="https://wilfswann.co.uk/work/heata/" title="HEATA">HEATA</a></li>
    <li class="work-heatsaver page_item page-item-136"><a href="https://wilfswann.co.uk/work/heatsaver/" title="HeatSaver UK">HeatSaver UK</a></li>
    <li class="work-human-after-all page_item page-item-130"><a href="https://wilfswann.co.uk/work/human-after-all/" title="Human After All">Human After All</a></li>
    <li class="work-miasma page_item page-item-56"><a href="https://wilfswann.co.uk/work/miasma/" title="Miasma">Miasma</a></li>
    
    <li class="work-muse-bliss page_item page-item-176"><a href="https://wilfswann.co.uk/work/muse-bliss/" title="Muse Motion – Bliss">Muse Motion – Bliss</a></li>
    <li class="work-muse-smbh page_item page-item-185"><a href="https://wilfswann.co.uk/work/muse-smbh/" title="Muse Motion – Supermassive Type">Muse Motion – Supermassive Type</a></li>
    <li class="work-digital-sketchbook page_item page-item-134"><a href="https://wilfswann.co.uk/work/digital-sketchbook/" title="The Digital Sketchbook">The Digital Sketchbook</a></li>
    <li class="work-operation page_item page-item-267"><a href="https://wilfswann.co.uk/work/operation/" title="The Operation Branding">The Operation Branding</a></li>
    <li class="work-the-operation page_item page-item-143"><a href="https://wilfswann.co.uk/work/the-operation/" title="The Operation online">The Operation online</a></li>
            </ul>
         </div>
    
      </div><!-- #nav -->

    not entirely sure what I am doing wrong, there are definitely pages with the custom field ‘class’ and value ‘print’.

    Thread Starter wilfswann

    (@wilfswann)

    my navigation happens to be in header.php here’s the code

    <div id="nav">
        <div id="topnav">
        	<ul>
              <?php wp_list_pages('depth=1&title_li=&exclude=8'); ?>
            </ul>
        </div>
        <div id="subnav">
            <ul>
              <?php wp_list_pages('depth=1&title_li=&child_of=8'); ?>
            </ul>
         </div>
    
    <?php
    	$my_pages = get_pages('meta_key=class&meta_value=print');
    	$html= '';
            if(!empty($pages)){
    	$html .= '<ul>';
              foreach ($my_pages as $pagg) {
      	    $html .=  '<li class="print"><a href="' . get_page_link($pagg->ID) . '">';
      	    $html .=  $pagg->post_title . '</a></li>';
              }
            $html .= '</ul>';
            echo $html;
            }
    ?>
    
      </div><!-- #nav -->

    ideally yes “web” and “motion and “print” would be with the same key (class) and structure

    Thread Starter wilfswann

    (@wilfswann)

    thanks for your help keesiemeijer. I tried that code but it doesn’t seem to produce any results. Perhaps I am implementing it wrong, is there anything I need to do other than include it in header.php? Also what changes would be needed to the code to add other meta values such as web and motion?

    Thread Starter wilfswann

    (@wilfswann)

    Okay I’ve had a read through of the meta documentation. Ideally I would like to be able to have a custom field called ‘class’ to which I could add a value of ‘print’ for my print work. Then a bit of script simply turns the <li><a href="printwork">Print Work</a></li> into <li class="print"><a href="printwork">Print Work</a></li>

    I think it’s possible to get the custom field value using something like <?php $meta_values = get_post_meta($post_id, $class); ?> but that only works for getting the field value for a specific page. Is it possible to integrate that somehow with wp_list_pages or something similar? I’m sorry for my lack of knowledge with these issues

    You can get an idea of what I’m trying to do on my website https://wilfswann.co.uk/work/futurism/ the list of work on the left hand side I want to be sortable into different sections based on the type of work it is :- web, print, motion etc. I plan to do this with jQuery, all i need is for the different types of work to have corresponding classes.

    Thread Starter wilfswann

    (@wilfswann)

    I did look into that but the codex doesn’t go into how to integrate that into the wp_list_pages and I am not sufficiently versed in php to know how to do that myself.

    Any help would be greatly appreciated.

    Thread Starter wilfswann

    (@wilfswann)

    Sorry, should have specified. They are pages, this is for a portfolio site, I use the pages to display my work and also include a blog so can’t use posts to display my work.

Viewing 15 replies - 1 through 15 (of 15 total)