Use get_permalink
(which returns the URL) instead of the_permalink
(which prints the URL).
Try:
foreach ( $categories as $category ) {
$link = get_term_link( $category );
$html .= "<li><a href="https://wordpress.stackexchange.com/questions/159187/{$link}" data-filter="{$category->category_nicename}">{$category->cat_name}</a></li>";
}
Related Posts:
- hover image appears below placeholder instead of overlayed
- combine Code 1 with Code 2
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Adding wp_list_categories to a specific div that was appended using jQuery
- How to change links in the 3 main categories, on widget category, to a javascript function call
- Conditional Header in wordpress
- Creating a related post section based on similar categories
- Swapping wp_dropdown_categories function with wp_category_checklist
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- How to select the contents in the text view textrea in wp_editor?
- wordpress count link clicks by ip address
- ajax, right way to do it and make it works?
- Filter Select results based on selection
- What is an equivalent of single_cat_title for getting the slug of the category?
- Is there a way to programmatically create multiple pages utilizing the same template but different content from a json file?
- Ajax load more posts with multiple tax query
- Issue adding sub category programmatically
- WordPress Sending data to Ajax with select option
- WordPress ajax doesn’t display object method on jQuery .change() function
- Ajax loaded form replaces form action with Ajax url
- How to exclude category ID from Looper in WordPress
- prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site
- Add a specific part of current category page url to shortcode
- how do I get a specific post from a post with a subcategory in WP
- How to design a table based on css values set from admin/dashboard
- WP grandchild categories in nested ul li
- Grab posts by multiple categories
- How to show single category archive
- Adding Custom Slider
- Move category description below post list in blog
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Ajax date_query not working past the first iteration
- Get page that displays all children of taxonomy parent
- Ajax request not sending to server and returning – wp-admin/admin-ajax.php 400
- Why ajax doesn’t work on certain wordpress hooks and reload the page instead?
- AJAX pagination, update current page
- Limit Widgets to Sidebar ID’s
- Save Search System
- adjust section according to country?
- populate form fields in a loop with ajax
- dynamic dependent select dropdown
- Change “add to cart” button color based on Woocommerce product category [closed]
- selected option if current category is the value
- How can I get the values of my WordPress $wpdb query in Jquery?
- Ajax request returns ‘Array’. How to output the actual results?
- Ajax load more button for comments wordpress
- Slick + PHP + ACF + JQuery slide reveal not working
- get_template_part based upon post’s category
- How to add a do_action on refreshing of WP customizer?
- how to save selected option in variable for rest api category filter
- Setting default category base on theme activation
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Hide subcategories (widget)
- Gravity form built in Captcha
- Alert Bar section within WP loop is displaying even though there are no posts
- Let Users Choose Post Categories
- Menu jumping when calling it via PHP
- Different post styles depending on category
- Setting value of session with Ajax not working
- Display category name only once inside loop
- Click a radio button must set textfield value
- WordPress Multiple Navigation bars
- [jQuery]Adding shortcode
- multiple taxonomy select display only one in front end
- Display parent and child taxonomies in separate drop down select fields
- Show success or error messages in Ajax response to WordPress custom registration form
- How to add a Custom Mailchimp AJAX Newsletter Subscribe Form
- Add / Update Custom Fields After Select Pictures in Media Window
- Post repeating with infinite scroll
- Plugins not working on AJAX requests
- How to show only subcategories in parent category not parent category?
- Fancybox type popup window that’s not an iframe
- How to disable controls in theme customizer?
- Can I use a jQuery Ajax request in Code Snippets Plugin for WordPress?
- JQuery calling a Custom PHP function (Works in Dev but not in WordPress)
- Jquery function working in Dev Console but not otherwise [duplicate]
- Form Security: nonce vs. jQuery
- how to show only specific category for a template
- How do I Import / Upload Files with jQuery AJAX?
- WordPress admin-ajax.php 400 bad request
- Why does wp_head hook my functions to the beginning of my source code?
- WordPress Ajax Call inserting data but success response false
- Dilemma of Populating all the categories in a drop down list
- Automatically set all tags to have a height of 0 if there is no content inside the tag [closed]
- Display most popular posts of category
- Ajax contact form return 0
- Creating sub-categories via php
- How can i display a jquery slide on front page
- AJAX – Returning Two JSON Objects with One PHP Function
- Pull GetOption() variable into jQuery dynamically created html
- Royalty-Free Sliders used in theme development
- Define specific category name in PHP
- Edit the_category (); for a hierarchical display
- JSON REST API WordPress only showing first 10 categories
- Category title output before opening title tag
- Error – ‘create_function is deprecated’ [closed]
- get taxonomy thumbnail and use it as a variable in code
- What are the advantages/disadvantages of using jQuery DOM manipulation as opposed to PHP DOM manipulation?
- Include Parent Term in wp_list_categories