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

Anonymous functions usage

Use the second option. Adding anonymous functions as filters and actions is highly discouraged!!! If you add an anonymous function in this fashion, it’s impossible to remove later on down the road by other plugins and code. So please, please, please don’t do that.

wordpress sql posts query won’t display the latest post in a specific category

I’d suggest using the WP_Query() class for this one. Hopefully the below will help you – <?php $args = array( ‘category_name’ => ‘photography’, ‘post_status’ => ‘publish’, ‘post_type’ => ‘post’, ‘posts_per_page’ => 5 ) $work_items = new WP_Query($args); if($work_items->have_posts()) : while($work_items->have_posts()) : $work_items->the_post() echo “<li>”; echo “<a href=”#” onClick=’title_to_contents(“.json_encode(get_the_title()).”)’>”; echo get_the_title(); echo “<span class=”project_date”>”.get_the_time(‘Y’).”https://wordpress.stackexchange.com/”.get_the_time(‘M’).”</span>”; echo “</a>”; … Read more

How to deal with a GET variable of ‘name’?

In case it’s useful for someone else in this situation, I ended up creating a page outside WordPress which renames the ‘name’ parameter (to ‘username’) and then redirects to the page I originally wanted to hit. My code for this external page is: <?php $data = array(‘UID’ => $_GET[‘UID’], ‘username’ => $_GET[‘name’], ‘ANI’ => $_GET[‘ANI’], … Read more

Page load timer?

$starttime is undefined in your footer, so you’re subtracting nothing from endtime. declare global $starttime first and it’ll work. that said, it won’t be a very accurate indicator of rendering time, since most of the work WordPress does happens before you ever reach the template and start your timer. There’s already a built-in timer that … Read more