Saving fields in a drop-down in WordPress

This is the code from the WordPress core code – line 580: <label class=”screen-reader-text” for=”page_template”><?php _e(‘Page Template’) ?></label> <select name=”page_template” id=”page_template”> <option value=”default”><?php _e(‘Default Template’); ?></option> <?php page_template_dropdown($template); ?> </select> The only thing different from your code is <option value=”default”>. So I don’t think your code is the problem. Also the code for page_template_dropdown isn’t … Read more

Cinema site, retrive the movies that actor play in

I think you want to list actors worked in a movie on the Movie Page and Vice Versa,, right ? Then you should consider using plugin called post-to-post to connect your Movies posts and Actors posts. Recently I came across an article by one of the WP developers itself, He developed a similar kind of … Read more

Only show image from custom field when present

<?php $imageid = get_post_meta($post->ID, ‘imageembed’, true); if($imageid != ”) { ?> <div class=”newsimage”><img src=”https://wordpress.stackexchange.com/questions/57967/<?php echo wp_get_attachment_url( $imageid ); ?>” width=”640″ /></div> <?php } ?> Use if condition to check if $imageid has any value in it or not.

Apply class to every third list item? [duplicate]

add a simple counter and conditional check: $pages = get_pages(‘child_of=10’); $counter = 1; if ($pages) { echo ‘<ul class=”projectthumbs”>’; foreach ($pages as $page) { if ($counter == 3){ $class=” class=”YOUR_CLASS””; $counter = 1 }else{ $class=””; $counter = $counter +1; } echo ‘<li’.$class.’><a href=”‘.get_permalink($page->ID).'”>’; echo get_the_post_thumbnail($page->ID); echo ‘<span class=”projectthumbtitle”>’; echo get_the_title($page->ID); echo ‘</span>’; echo ‘</a></li>’; } … Read more

How to use array in function to get only value I want

There’s wp_list_pluck() to get certain fields out of arrays or objects: $object = new StdClass(); $object->foo = ‘Hi!’; $object->bar=”Yo!”; $array[‘foo’] = ‘Hi!’; $array[‘bar’] = ‘Yo!’; $result_obj = wp_list_pluck( $object, ‘foo’ ); var_dump( $result_obj ); // Result: string (3) Hi! $result_array = wp_list_pluck( $array, ‘bar’ ); var_dump( $result_array ); // Result: string (3) Yo!

Making my first wordpress template

Use this code to show the content of a post or a page: <?php the_content() ?> Use this code to show the title of a post or a page: <?php the_title() ?> This page can be useful if you are new to designing WP themes: http://codex.wordpress.org/Site_Design_and_Layout Here is a list of the template-tags you can … Read more