display sticky post outside loop and exclude from loop

Before your loop do: $args = array( ‘ignore_sticky_posts’ => 1 ); $query = new WP_Query( $args ); // The Loop while ( $query->have_posts() ) : $query->the_post(); echo ‘<li>’; the_title(); echo ‘</li>’; endwhile;

Custom Database Table and foreach

Assuming you have table that’s prefixed with the WordPress prefix (even if it’s not the default one), and the table is called table. Then the following code should select everything, and allow you to go through each row. In this example, it goes through each row and outputs the content of the field foobar. global … Read more

Modify pages widget and make a plugin?

Widgets are class based, so it is quite easy to extend them. Create your class by extending WP_Widget_Pages (just like it extends baseline Widget). Copy method(s) you want to modify into your class and make changes in there. You would probably want to extend and modify name and such so it is not confused/conflicted with … Read more

How to get the second slug of a page url?

This problem can be solved with the WordPress Rewrite API The simplest way I assume that you’ve created a page called year and the request is most probably matched to this rule (.+?)(/[0-9]+)?/?$, with the query rewritten to pagename=year. However, you will notice from the regular expression that an additional / can be matched to … Read more

How to load previous or next attachment with jquery ?

@milo thanks ! i used a technique found on the page you sent. it’s almost working. I added this at the end of the previous single.php code : array_unshift($attachments_list,””); wp_enqueue_script(‘myscript’); wp_localize_script(‘myscript’, ‘attachments_list’, $attachments_list); To work, this code must be called before wp_head(). Then, for a mysterious reason, the first element (with the index 0) is … Read more

Show Custom Menu Name in WordPress 3

Yes, you can display the name of custom menu in the frontend. All you need to know is the menu location identifier. This is the same id which is used in register_nav_menu() function. Here is the code: <?php $menu_location = ‘primary’; $menu_locations = get_nav_menu_locations(); $menu_object = (isset($menu_locations[$menu_location]) ? wp_get_nav_menu_object($menu_locations[$menu_location]) : null); $menu_name = (isset($menu_object->name) ? … Read more