kelune
Forum Replies Created
-
<?php $args = array( 'post_type' => 'attachment', 'numberposts' => 1, 'post_status' => null, 'post_parent' => $post->ID ); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { echo apply_filters('the_title', $attachment->post_title); the_attachment_link($attachment->ID, false); } } ?>
Forum: Plugins
In reply to: wp_list_pages changing class 'page-item-#' to page name?Alright, maybe I’m not being specific enough:
I have a custom nav that sets a class for each link that is the same as the page title:
<li id="home"><a href="home">Home</a></li>
Additionally, it sets the active class for the parent if you are on any child pages:
<li<?php if ( is_page( 'we-do-well-when-our-clients-do-great' ) || '3' == $post->post_parent) { echo ' class="active"'; } ?> id="home"><a href="home">Home</a></li>
In addition to THAT, it also adds another language via qtranslate:
<li<?php if ( is_page( 'home' ) || '3' == $post->post_parent) { echo ' class="active"'; } ?> id="home"><a href="home"><?php if(qtrans_getLanguage()=='en'): ?>Home<?php endif; ?><?php if(qtrans_getLanguage()=='es'): ?>Inicio<?php endif; ?></a></li>
I’d love to use wp_list_pages for this with a nice string of arrays, but I can only get so far as
<?php wp_list_pages('sort_column=menu_order&depth=1&title_li=&exclude=45'); ?>
with an additional function to get the top parent page id in order to turn that link as active.What I’d like to do is to create a function that replaces
<li class="page_item page-item-3 current_page_item"><a href="home" title="home">home</a>
with something more dynamic, so that the classes of each link would not have to be edited if page-ids change. For instance:<li class="home active"><a href="home" title="home">home</a>
I’ve found ways to call the current page name, but was wondering how to grab that page name from somewhere else so that I could turn all of this into a much easier to use function. I know enough to mesh things together to get an output that I want, but not enough to create something completely from scratch. I’m sorry if I’m not seeing anything related to what I’m looking for with get_pages or wp_list_pages. If you or anyone else could help point me in a more clearer direction to get the title of a listed parent page into a class, it would be a great help.
Forum: Plugins
In reply to: wp_list_pages changing class 'page-item-#' to page name?Yes, that is exactly where I’m trying to go.
FYI, I put this in to get it working:
<?php $meta_value = get_post_meta( $post->ID, 'post_second-image_thumbnail_id', true); $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); echo '<img src="' .$image[0]. '" style="width:'.$image[1].'px"; height: '.$image[2].'px"/>'; ?>