Tag Info

New answers tagged

0

I too wanted to do something similar. I found a plugin called JinMenu that allows you to add onClick code to your menu items. On our page, we have a form with the attribute name="_xclick". After installing the plugin, I was able to add this to my onClick event: document.forms['_xclick'].submit(); return false; That triggers my form when the menu item ...


0

To show next and previous links independent of whether or not any more pages are present you need to add some conditional statements: <div class="navigation"> <?php if (!empty($prevID)) : ?> <div class="previous"> <a href="<?php echo get_permalink($prevID); ?>" title="<?php echo get_the_title($prevID); ...


1

I don't have the time to work out a complete solution (which could be pretty complex) but, if I am reading things right, by default WordPress uses Walker_Nav_Menu_Edit to create those backend menus. It looks to me like you can build your own walker for the backend and pass it in via the wp_edit_nav_menu_walker hook. If you did that, you should be able to ...


0

This is a problem that I see come up quite often. I think that the WP_List_Pages solutions I see all over are a bit old school now that Wordpress has a proper menu manager (Appearance -> Menus). I have tried numerous solutions including some plugins/widgets and walkers like the one above. I have never been very pleased with the available solutions. I ...


0

You will need to add a class to the correct menu item yourself. Here is a similar example which you can modify according to your needs: http://wpthemetutorial.com/2013/05/14/filtering-classes-on-wp_nav_menu/


2

The code in question is in header.php, line 45. <?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?> This is the Codex reference to this function: wp_nav_menu. From my experience, and some googling, this previous answer has the answer you're looking for. If possible, would just adding a class to the ...


1

If you want to return an array of items (not output like wp_nav_menu), you can try this: $menu_name = 'your_menu_location'; if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) { $menu = wp_get_nav_menu_object( $locations[ $menu_name ] ); $menu_items = wp_get_nav_menu_items($menu->term_id); foreach ( ...


0

In case anyone else is looking for this in the future, turns out the best way to do it is by using wp_get_recent_posts function. Someone knocked up an example that worked great for me: <?php $args = array( 'numberposts' => '1' ); $recent_post = wp_get_recent_posts( $args ); if (strtotime($recent_post[0]['post_date']) > strtotime('-7 days')) ...


2

Use ancestors: $ancestors = array_reverse( get_post_ancestors( $post->ID ) ); // reverse ancestors to make it more intuitive if ( isset( $ancestors[0] ) ) { if ( isset( $ancestors[1] ) ) { // 3rd tier $parent_id = $post->post_parent; } else { // 2nd tier $parent_id = $post->ID; } $args = array( ...


0

Use the arguments before and after: wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'before' => '<span>', 'after' => '</span>' ) ); To see how these arguments are used, look at the method start_el() in Walker_Nav_Menu: $item_output = $args->before; // ...


0

I wasn't able to find something that would add an id, but I did find something that would give me a class...this way I can target the class using jQuery. The default id's and classes are ok, but the solution I found is much better because no matter which website you apply it to it will work, I don't ever have to go back and change the link class or id. I was ...


0

Well, you can do it with jQuery, if your links are inside a div with given ID of 'menu', so you could write: <script type="text/javascript"> var links = jQuery('#menu').find('a'); jQuery(links).each(function(){ jQuery(this).addClass('news'); // It will add a class for all links, not an id jQuery(this).attr('id', 'news'); // This will add an id, but ...


0

I have a few issues with the accepted answer - that doesn't make it wrong, but I'll post my own code below which I feel might have a better result for some people since I had the same question but wanted to do the same thing with less code. First, the above code creates "URL" type navigation items, which is fine for some people but I want to link to PAGES, ...


2

Check out get_next_post_sort and get_previous_post_sort filters. You can modify the ORDER BY clause to whatever you want (including ). For example, if you want to sort the 'next post' to be the post with the smallest adjacent post ID: function wp28041_get_next_post_sort($where){ return 'ORDER BY ID ASC LIMIT 1'; } add_filter('get_next_post_sort', ...


0

You are not setting the $paged parameter anywhere in that code. You need a line something like this: $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; It really looks like you should be using a function hooked to pre_get-posts as here and as in a lot of answer on the site.


0

Since this is not a WordPress function related question but CSS in general, I believe you shouldn't ask for help here. I do not understand the border thing. What is "access", class or id? Is your menu wrapper? Be more specific so we can answer you properly. The transition syntax: transition: property_name, duration, easing; Let's say you need to add ...


0

In order to get pagination working with secondary Loops, you have to pass the $paged parameter to WP_Query, other wise the query does not know which set of posts to load and will load the first set, page 1, every time. I got it to work by adding 'paged' => $paged inside the $args = array(); $args = array( 'post_type' => 'a-reports', ...



Top 50 recent answers are included