Datafeedr Support Forums  

Go Back   Datafeedr Support Forums > Current Version (V3) Forum > Tips, Tricks & Tutorials
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Important - The support forums are now in "read-only" mode as we transition to an alternative help desk solution. Feel free to contact us here with any of your questions or search the forums for an existing solution.
 
 
Thread Tools Search this Thread Display Modes
  #1  
Old December 8th, 2010, 08:41 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default Append Datafeedr Store Categories to Default WordPress Primary Menu

This appends a Datafeedr category menu to the main navigation in the theme TwentyTen. Your theme must make a call to wp_nav_menu() in order for this to work.

First, open your theme's functions.php and add the following to the bottom of your functions.php file:

PHP Code:
// Add store categories to nav menu 
function dfr_menu_items($items$args) { 
    if (
$args->theme_location == 'primary') { 
        
$cats str_replace(array("<div>","</div>"), array("",""), datafeedr_tag('Category List?c=%ci')); 
        
$items $items $cats
    } 
    return 
$items

add_filter'wp_nav_menu_items''dfr_menu_items'10);
// add_filter( 'wp_list_pages', 'dfr_menu_items', 10, 2 ); 
In the Factory, create a new Custom View and give it the name "Category List". Make sure to select "Don't use layout for this view" in the View's properties menu.

Add a Category list module to the view area. Add the following code in the template area of your new view:
HTML Code:
[category.list id='dfparent' before='' after='']
<li>
  <a href="[category.link]" title="[category.name]">[category.name]</a>
  [category.list id='dfchild' before='<ul>' after='</ul>']
    <li>
      <a href="[category.link]" title="[category.name]">[category.name]</a>
      [category.repeat id='dfchild']
    </li>
  [/category.list]
</li>
[/category.list]
Update your store and now your menu should load the default primary links PLUS your store's categories.

This code shows how to add categories as a sub-menu to the "Store" menu link: http://www.datafeedr.com/forums/show...1913#post21913

For more information, see:
http://wpfirstaid.com/tag/wp_nav_menu/
http://www.wpbeginner.com/wp-themes/...rdpress-menus/

Last edited by Eric : April 26th, 2011 at 06:43 PM. Reason: Updated function() for WP 3.1.1+
  #2  
Old January 9th, 2011, 09:44 AM
digitalcow digitalcow is offline
 
Join Date: Jun 2010
Posts: 494
Default

Eric, followed the first post and nothing is showing up in my template. Re the 2nd post where should I enter str_replace(array("<div>","</div>"), array("",""), datafeedr_tag('Category List?c=%ci')); ? I assume echo str_replace(array("<div>","</div>"), array("",""), datafeedr_tag('Category List?c=%ci')); will go in the header of the template?
  #3  
Old January 9th, 2011, 09:47 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by ccgmark View Post
Eric, followed the first post and nothing is showing up in my template. Re the 2nd post where should I enter str_replace(array("<div>","</div>"), array("",""), datafeedr_tag('Category List?c=%ci')); ? I assume echo str_replace(array("<div>","</div>"), array("",""), datafeedr_tag('Category List?c=%ci')); will go in the header of the template?
Did you have a look at this thread: http://www.datafeedr.com/forums/showthread.php?t=3554
  #4  
Old January 24th, 2011, 08:28 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

You could try creating a Primary Menu using the WP menu system. Then replacing the function Atahualpa uses to generate the menu with the WP native function wp_nav_menu(). You'll need to pass a few parameters into that function but maybe the Atahualpa devs could tell you how to do that.
  #5  
Old February 17th, 2011, 07:48 PM
grooves1200 grooves1200 is offline
 
Join Date: Feb 2011
Posts: 23
Default

I tried this and all i'm getting is a second version of "Store" on the top navigation. I did not see a closing ?> tag in the functions.php so i added one, but no luck. any ideas?
  #6  
Old February 17th, 2011, 08:47 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

You don't need a closing tag. What WP theme are you using? The instructions I posted are for the default WP theme TwentyTen. If you are using a theme that implements the menu system differently, you might need to modify this.
  #7  
Old February 17th, 2011, 08:48 PM
grooves1200 grooves1200 is offline
 
Join Date: Feb 2011
Posts: 23
Default

twentyten, right out of the box
  #8  
Old February 17th, 2011, 08:56 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Have you created the new menu on the WP Menus page? It's hard to troubleshoot without knowing what you have and have not already done.
  #9  
Old February 18th, 2011, 02:34 PM
grooves1200 grooves1200 is offline
 
Join Date: Feb 2011
Posts: 23
Default

sorry, i didn't see any instructions on creating new menu on the menus page. still a newbie!
  #10  
Old March 14th, 2011, 03:57 AM
winsh winsh is offline
 
Join Date: Jan 2011
Posts: 40
Default

Thanks for this code but could you tweak it so it only shows the store categories in the nav bar code? as I will put the blog categories in a widget.

Thanks
  #11  
Old March 14th, 2011, 09:06 AM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

You just need to get the name of the nav menu and substitute wp_nav_menu_primary_items with the new name. I'm not quite sure where you get that name from, though.
  #12  
Old March 15th, 2011, 06:56 PM
sovarn sovarn is offline
 
Join Date: Mar 2011
Posts: 1
Default

I have created a new menu called "products". But what is the correct add_filter to append the function to that particular menu?
  #13  
Old March 15th, 2011, 07:16 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

I'm not exactly sure... Are you sure it's not wp_nav_menu_products?
  #14  
Old April 26th, 2011, 07:13 PM
onlineshopper onlineshopper is offline
 
Join Date: Mar 2011
Posts: 13
Default

I am so sorry Eric. I feel so helpless. I added the code to the functions.php. Now I have two sets of categories in my menu. One with a drop down and one without. I think I should take some of the code out, but don't know which one.
  #15  
Old April 26th, 2011, 07:16 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Try this code in your functions.php file instead
PHP Code:
// Add store categories to nav menu
function dfr_menu_items($items) {
    
$cats str_replace(array("<div>","</div>"), array("",""), datafeedr_tag('Category List?c=%ci'));
    
$items $items $cats;
    return 
$items;
}
add_filter'wp_nav_menu_items''dfr_menu_items' ); 
  #16  
Old April 26th, 2011, 07:21 PM
onlineshopper onlineshopper is offline
 
Join Date: Mar 2011
Posts: 13
Default

Still have two sets. Is it easier to send you the backend info?
  #17  
Old April 26th, 2011, 07:27 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by onlineshopper View Post
Still have two sets. Is it easier to send you the backend info?
Sure.
  #18  
Old April 26th, 2011, 07:42 PM
Eric's Avatar
Eric Eric is offline
Datafeedr Team
 
Join Date: Feb 2008
Posts: 16,902
Default

Quote:
Originally Posted by onlineshopper View Post
Still have two sets. Is it easier to send you the backend info?
The reason you had 2 sets is because you added them once in your functions.php file and once on your Menu's page. I deleted all of the pages you added via your Menus page and now all looks fine.

If you want to add an additional NON-datafeedr link to your nav bar, you can do so from the menus page.

Eric
  #19  
Old April 26th, 2011, 07:44 PM
onlineshopper onlineshopper is offline
 
Join Date: Mar 2011
Posts: 13
Default

Thank you so much!!!
  #20  
Old July 1st, 2011, 06:31 PM
teeshirtdrama teeshirtdrama is offline
 
Join Date: Mar 2009
Posts: 50
Default

Hi
I followed the instructions above and all my datafeedr categories were added to my home page menu. Is there a way to make one menu option such as store and then make it so all the categories fall under this or drop down? It may be mentioned but just do not understand exactly how that can be done.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:22 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.