Display child pages on a parent and child page using Featured Thumbnails

Use get_ancestors to get the page parent, then get the children of that parent. $ancestors = array(); $ancestors = get_ancestors($post->ID,’page’); $parent = (!empty($ancestors)) ? array_pop($ancestors) : $post->ID; if (!empty($parent)) { $kids = new WP_Query( array( ‘post_parent’=>$parent, ‘post_type’ => ‘page’, ‘ignore_sticky_posts’ => true ) ); if ($kids->have_posts()) { while ($kids->have_posts()) { $kids->the_post(); echo ‘<a href=”‘.get_permalink().'” title=”‘.get_the_title().'”>’.get_the_post_thumbnail().'</a>’; … Read more

get_pages – Display child then grandchild pages

You don’t need 2 queries, just use a bit of logic and 2 foreach loops: $portfolioID = $post->ID; $portfolio_sections = array( ‘post_type’ => ‘page’, ‘child_of’ => $portfolioID, ‘sort_column’ => ‘menu_order’, ‘sort_order’ => ‘ASC’, ); $sections = get_pages($portfolio_sections); $hierachical = array(); if ( ! empty($sections) ) { foreach ( $sections as $section ) { if ( … Read more

Add post title as alt tag for featured image

@its_me got it almost right. Those args must be 2nd resp. 3rd Parameter, not first: $attr = array( ‘title’ => ‘howdy partner’, ‘alt’ => ‘a nice view of the ocean’, ); // pick one, note 2 or 3 arguments: the_post_thumbnail( ‘post-thumbnail’, $attr ); echo(“<a href=”https://wordpress.stackexchange.com/questions/57968/$p->permalink”>”. // null for current $post->ID (use within loop) get_the_post_thumbnail( null, … Read more

Specific featured image for each category

<?php if(has_post_thumbnail()) the_post_thumbnail(‘themolio-featured-image’); else echo wp_get_attachment_image($attachment_id, ‘themolio-featured-image’); ?> The above code displays the featured image if the post has one, otherwise the image define by $attachment_id. I don’t know how you’re deciding which category term should display which image & what to do in case of multiple categories, so the part where you initialize $attachment_id … Read more

Change wording of default thumbnail metabox

This is usually what I go with: /** Use “Featured Image” Box As A Custom Box **/ function customposttype_image_box() { remove_meta_box(‘postimagediv’, ‘page’, ‘side’); add_meta_box(‘postimagediv’, __(‘Set Dat Image’), ‘post_thumbnail_meta_box’, ‘page’, ‘side’); } add_action(‘do_meta_boxes’, ‘customposttype_image_box’); /** Change “Featured Image” box Link Text **/ function custom_admin_post_thumbnail_html( $content ) { global $post; if($post->post_type == ‘page’) { $content = str_replace( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)