Tag Info

New answers tagged

1

I believe, most obvious choice would be to create two categories "Fall-Winter" and "Spring-Summer" and put four other categories in both of them. Your URLs would be like this /category/fall-winter /category/fall-winter/formal-wear /category/fall-winter/night-wear Now, to list the formal wear for both fall-winter and spring-summer on page, we have few ...


3

You have two calls to wp_nav_menu function <?php if( has_nav_menu( 'primary-menu' ) ) { wp_nav_menu( $menuParameters = array( 'theme_location' => 'primary-menu', 'container' => '', 'container_class' => false, 'container_id' => false, 'menu' => 'Primary', 'menu_id' ...


0

Why not just use the function array_chunk() ? Assuming you built out an array of finished <li> tags, your code to split and display them might look like this: $columns = array_chunk( $myArray, 4 ); foreach ( $columns as $column ) { echo '<li>' . $column . '</ul>'; }


0

I have achieved same with this: function add_custom_menu_item(){ add_menu_page( 'Menu Item Title', 'Page Title', 'manage_options', 'page_slug', 'function', 'dashicons-icon', 1 ); } add_action( 'admin_menu', 'add_custom_menu_item' ); function custom_menu_item_redirect() { $menu_redirect = isset($_GET['page']) ? $_GET['page'] : false; ...


0

What you might be looking for is http://scrollnav.com. We use this for Aesop Story Engine in our Chapter and Timeline components.


0

You can add category item Current Tenders in your menu directly which shows all the post of your category Current Tenders.


1

Wordpress allows you to create custom page templates. Create your own template and assign that template to any page you like in the WordPress admin ;)


1

I agree with ialocin, if you can use the built-in nav menu css classes you should but if those aren't enough there's a nice little filter which can help with css classes. If you need something other than CSS classes you can use a Custom Walker ( as ialocin suggested ) and use the same logic as the function below. Add some CSS Classes to WP Nav Menu /** ...


0

You can create a menu use another language. Then you use conditional code to switch the menu. or you can use title attribute of menu. if($language=='us'): wp_nav_menu(menu1); else: wp_nav_menu(menu2); endif;


0

I've got the filter just for you: nav_menu_css_class function wpse_175057_nav_menu_css_class( $classes, $item ) { if ( $item->type === 'post_type' && $class = get_post_meta( $item->object_id, '_icon', true ) ) $classes[] = $class; return $classes; } add_filter( 'nav_menu_css_class', 'wpse_175057_nav_menu_css_class', 10, 2 );


0

I have deleted the nav.php file from my header.php, and added back the old menu code that comes with Wordpress. I did some hooking into my style.css file to adjust the styles for the desired design and I only used the #menu-navmenu that I created in WordPress to float right my menu bar. ul#menu-navmenu{float: right;} So before I had this ul#menu {float: ...


0

In your PHP file, set $thisPage before you include('nav.php');. Then, the variable $thisPage will be passed to nav.php and processed in its if statement. This is really bad practice though, and a better way of doing it would be by creating your menu in WordPress itself and hooking it into your template. WordPress documents how to do this well.


0

To see the menu, you need to set it up in the wordpress admin side. Go to Appearance -> Menus You should see a "Manage Locations" tab. Select it. You should see your "Main Menu" location. Choose the menu that you created there. Select Save Changes. Since you used "theme-location" to set up drawing it, you need to set a menu to your theme location to ...


0

What I would do is remove all that code you have in nav.php displaying the menu, create the menu inside the Wordpress backend, then you'll be able to use .current-menu-item in your css. Then all you need to call the menu will be wp_nav_menu(); Here is the documentation for that function: http://codex.wordpress.org/Function_Reference/wp_nav_menu


0

If your theme is using wp_nav_menu() you will have the class current-menu-item added to the relevant <li> element for you. Does this help?


1

Register a menu is really register a menu location, but I think you don't need to register locations so you can avoid the register step. I think what you need is wp_nav_menu( ) function. For example, in the page template: //Get the menu slug stored in page custom meta field //Replace menu_meta_field_name with the correct name of the meta field $menu_slug = ...


1

You are missing a link. The posts are not assigned to the menus directly. There is a post type nav_menu_item in nav_menu taxonomy which links posts (or other kinds of destinations) to their place in menu. This snippet should get you started on retrieval: $menu_items = get_posts( [ 'post_type' => 'nav_menu_item', 'meta_query' => [ [ ...


0

I had to do something similar recently and figured out another way. I had to add a similar class for a Nivo lightbox plugin. So I added "nivo" to the rel attribute ("Link Relationship (XFN)") and then the following on the nav_menu_link_attributes filter. function add_nivo_menuclass($atts, $item, $args) { if( is_array($atts) && ...


0

You can not get the menu title using wp_nav_menu(), you need to get the menu object as follow: //Change with the ID of your menu $menu_ID = 5; $nav_menu = wp_get_nav_menu_object( $menu_ID ); // then echo the name of the menu echo $nav_menu->name; With the above code, you can insert the menu name in wp_nav_menu() using items_wrap parameter. For example: ...


0

Yes, Finally i had done it. I done changes in nav-menu-template.php. I created one variable and initialized with 1 above foreach ( (array) $menu_items as $key => $parent_item ) { this code. and add conditional code if($repetation == '1'){//to stop second selection of menu $classes[] = 'current-menu-parent'; ...


1

Sorry this should be a comment --> you should be able to use a switch to blog http://codex.wordpress.org/Function_Reference/switch_to_blog This will allow you to grab the main blog ID, from there you can use a WP list pages or a http://codex.wordpress.org/Function_Reference/wp_nav_menu to display the menu of your main site on the other blogs within the ...


0

When I need a custom php page that works with Wordpress, generally I do this: I add a query variable to variables permitted by Wordpress: add_filter( 'query_vars', 'myplugin_add_query_var' ); function myplugin_add_query_var( $query_vars ){ $query_vars[] = 'myplugin_page_name'; } I add a function to parse_request action that check if is set the ...


-1

You can create a custom post type with register_post_type() function with false as show_ui parameter like this. //code is taken from codex //custom post type name is book here. Change the post type name and other options as your need //Set `show_ui` and `show_in_menu` false add_action( 'init', 'codex_book_init' ); function codex_book_init() { $labels = ...


0

If you've got a wp_nav_menu instance for your menu, you can add a filter to dynamically add menu items when the menu is printed to the page. The filter for all nav menus is wp_nav_menu_items. For specific menu slugs, the filter is wp_nav_menu_{$menu->slug}_items. For example, if your menu slug is primary, the filter would be wp_nav_menu_primary_items ...


0

Well, inside your directory just keep a normal php file like my-page.php, and then create a vanity URL for it using .htaccess. Open your .htaccess file (if present in the nstallation directory) or create one RewriteEngine On RewriteRule ^my-page-slug my-page.php Should be good update if you want to access WP posts and other objects, you must include ...


0

If you want to do something like a "Back to previous page"-link that will probably not work with the WP menu system. But you could modify/add your theme and use $_SERVER['HTTP_REFERER'] (PHP manual) to link back to the site, where the user clicked the link to the actual page. But that information can also be altered or not be available due to privacy ...


1

The taxonomy archive menus have the classes menu-item-type-taxonomy and menu-item-object-{taxonomy-name}, so there is nothing strange because category is a taxonomy (here you are wrong when say that "the menu is a link to the category and archive page, not a taxonomy").


3

Filter kses_allowed_protocols (wp-includes/functions.php wp_allowed_protocols) to add your protocol: add_filter( 'kses_allowed_protocols', function( $protocols ) { $protocols[] = 'weixin'; return $protocols; }); The default values are 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', ...


0

This sounds suspiciously like the conflict that happens sometimes when tag taxonomies, custom post types, and menus collide in a weird way. I have only found hacks for this issue, and many of them are listed in this thread on WordPress.org.


0

First: congrats! The links are well formed, so that is not your problem. <a id="rsvp" rel="m_PageScroll2id"></a> Is not the convention in HTML5 anymore. You should prefer to put the ID in your H2 element. Something like this: <h2 class="entry-title" id="rsvp">RSVP</h2> Using Google Chrome, when I tried that, I still got the ...


0

I did a similar thing in many of my projects, here's how I did it: <div class="user-panel"> <ul> <?php if (is_user_logged_in() ) { // When the user is Logged-in $current_user= wp_get_current_user(); echo '<li>'. __( 'Welcome, ', 'text-domain' ) .'<strong>'. ...


0

Finally I was able to find a way to do exactly what I wanted. Though adding Custom Taxonomy or Custom Post Type can easily be added, while having its Template file, as following: Appearance> Menus > selecting Links widget > putting link of custom post type or taxonomy http://yourdomain.com/your-custom-post-or-taxonomy But also this answer help you to have ...


1

Basically you want to display a menu of child pages of "Sevice One" if you are in any child page of "Service One", a menu of child pages of "Service Two" if you are in any chiild page of "Service Two", and so on. This can be done with the child_of argument of wp_list_pages. We can fill this parameter dynamically using get_post_ancestors for current page and ...



Top 50 recent answers are included