Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$5
Getting the "href" category page on a filtering menu
I'm using a theme called "FolioGrid" where there is a
wp_dropdown_categories($cats); ? filtering menu.I want to change the dropdown menu to a simple list "ul" with "li" display set has "list-item".
The menu has 3 links.
Here is the code of the original menu :
<div class="categories">
<?php
$cats = array('show_option_none' => __('Select Category', 'foliogridpro'));
wp_dropdown_categories($cats); ?>
</div>I wrote this and manage to have the menu display has list-item :
<div class="categories">
<?php
$cats = array('show_option_none' => __('Select Category', 'foliogridpro'));
$categories=get_categories($args);
foreach($categories as $category) { ?>
<li><a href="#" data-filter=".<?php echo $category->category_nicename; ?>"><?php echo $category->name; ?></a></li>
<?php } ?>
</ul>
</div>But I miss the link to the categories.
Here is the answer of the guy from support theme :
I imagine it won't filter as you don't have the 'href' set to go to that category page. It doesn't do the filtering with AJAX on this theme if that's what you are expecting? It goes direct to the category page.
Can anyone help me to manage to get the 'href' set to go to that category page.
Thanks a lot.
This question has been answered.
guillaume guillaume | 05/29/12 at 6:11am
Edit
(4) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
05/29/12
6:18amArnav Joy says:use this
<li><a href="<?php echo get_category_link($category->term_id; )?>" data-filter="<?php echo $category->category_nicename; ?>"><?php echo $category->name; ?></a></li>- 05/29/12 6:19am
Arnav Joy says:here is the full code
<div class="categories">
<?php
$cats = array('show_option_none' => __('Select Category', 'foliogridpro'));
$categories=get_categories($args);
foreach($categories as $category) { ?>
<li><a href="<?php echo get_category_link( $category->term_id )?>" data-filter="<?php echo $category->category_nicename; ?>"><?php echo $category->name; ?></a></li>
<?php } ?>
</ul>
</div> - 05/29/12 6:26am
guillaume guillaume says:Thank you Arnav.
It's working.
- 05/29/12 6:19am
-

Last edited:
05/29/12
6:18amrizaljohn says:You can try this:
<?php
// Get the URL of this category
$category_link = get_category_link( $category_id );
?>
<!-- Print a link to this category -->
<a href="<?php echo esc_url( $category_link ); ?>" title="Category Name">Category Name</a> -

Last edited:
05/29/12
6:20amJeffri Hong says:I think you need get_category_link to get the link.
Try this
<li><a href="<?php echo get_category_link($category->term_id) ?>" data-filter=".<?php echo $category->category_nicename; ?>"><?php echo $category->name; ?></a></li>
-------------------------------
Late by a minute. Please refer to answer above me instead.. :)Previous versions of this answer: 05/29/12 at 6:20am
-

Last edited:
05/29/12
6:19amIvaylo Draganov says:Hello,
There's no need to write custom functions - use wp_list_categories() instead.
<div class="categories">
<?php
$cats = array('show_option_none' => __('Select Category', 'foliogridpro'));
wp_dropdown_categories($cats); ?>
</div>
This question has expired.
guillaume guillaume voted on this question.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
