the_title() and the_permalink() are functions that automatically echoed. Use in this case get_the_title()
and get_permalink()
.
the code should look something like this:
while ( $query->have_posts($post->ID) ) : $query->the_post();
echo '<li><a href="'. get_permalink(). '">' .get_the_title() .'</a></li>';
endwhile;
Here is another way using the_title
and the_permalink
:
while ( $query->have_posts($post->ID) ) : $query->the_post(); ?>
<a href="https://wordpress.stackexchange.com/questions/191514/<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php endwhile;
Related Posts:
- Custom Taxonomy as Dropdown in admin
- wp_dropdown_categories in custom post type with custom taxonomy
- Conditional two level dropdown filter for custom post type
- Display custom taxonomy as dropdown list
- How to make custom taxonomy into drop down select in a custom metabox
- dropdowboxes with pre-selected custom fields optios that filters the results according seach needs
- Display Taxonomy Term Children in a Drop Down without Submit Button
- How to create Custom Taxonomy Search Drop Down for specific Post Type
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- Change dynamically the dropdown list value
- Changing an item in drop down after 5 latest posts per taxonomy
- Dropdown switching subcategories portfolio
- Auto Complete Search
- Custom Post Type Pagination Paginates Only in URL Structure
- Set post terms for multiple posts
- Load Custom_post_type categories post with ajax
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- Get terms that contain posts that in turn belong to other terms?
- WP-API select custom taxonomy when creating a post
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- First custom field value (out of several) displayed twice after query
- Custom post with more than one custom taxonomy
- How to get custom posts sub category link
- Custom while loop for hierarchical display of a taxonomy
- Terms showing up in object cache on unrelated pages
- Lists custom taxonomy terms that has specific custom field value assigned to the term (not post)
- Get the taxonomy of a post hierarchically
- Adding custom taxonomy in same menu place with two custom post types
- Including taxonomy term before post type breaks top level pages
- Correct procedure for advanced permalinks
- Permalinks: custom post type -> custom taxonomy -> post
- List Taxonomy Terms based on another Taxonomy
- How to get the intersection of two terms both from different custom taxonomies
- Create a Dropdown from Custom Post Type
- CPT’s with landing page instead of archive – Url Rewrite?
- Template for all categories of a custom post type?
- How to change permalink to include custom post type
- Add Custom Post Type of specific Custom Taxonomy to regularly blog loop
- posttype/taxonomy/term archive page 404 error
- How to add attributes to taxonomies that may be different from post to post?
- Display taxonomy terms, child terms and posts in a template
- Custom post type, permalinks, taxonomies and blog posts
- How to group posts and get a mixed posts and groups view?
- Custom post type permalink tag 404
- How to make front end form only accept certain values
- How to get list of taxonomy slugs ordered parents>childs?
- Custom Post Type by Taxonomy
- Deleting taxonomy terms and relationships on a custom post_type when a user is deleted
- Custom post type / taxonomy rewrite archive page 2 gives 404
- Use custom walker to add taxonomy terms to main nav menu
- Post format alternative?
- WP_Query orderby and tax_query
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- browse by category and tags?
- permalink /category/post-name with custom post type and taxonomy
- Taxonomy structure help
- Querying Custom Post Type, ordering by Custom Taxonomy Pagination Not Working
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Custom Taxonomy not being saved on custom posttype
- Create more category hierarchical depth for custom post type/taxonomy plugin (widget)
- Displaying Custom Taxonomies From Multiple Custom Post Types
- Hierarchial Custom Post Types/Taxonomies
- Custom post type and taxonomy permalinks
- How do I share categories across multiple post types?
- Exclude custom taxonomy term posts from custom post loop
- Hierarchical permalinks for custom post type and taxonomy
- Migrating a taxonomy’s tags to the native category
- Add term to custom post type on draft
- Multiple tag cloud filtering
- List of Posts and Categories
- Grouping of CPTs and taxonomies into menu groups in admin
- Best way to organize book-page structure
- Get url.com/post_type/taxonomy/term work!
- Displaying custom-taxonomy-terms sorted by parent/child-hierarchy?
- Invalid argument supplied in register_taxonomy $args->taxonomies
- set permalink for CPT
- Top Level pages in wordpress giving 404, but child pages working fine
- Sitemap generation
- Plugin fatal error
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Taxonomy/Custom post type structure suggestion on a movie site
- Search by tag name and category
- Taxonomy in URL
- Ordering values entered in Custom Taxonomies
- Listing all term items alphabetically / sorting loop
- How to produce a sub-page-system in WordPress
- Change the Custom Taxonomy URL Slug pattern
- Advanced search form with filters for custom taxonomies
- Custom taxonomy and post type with same slug
- Losing Nav Active State in Menu
- WordPress custom taxonomy template not working
- Listing custom terms in custom post meta
- Show fields based on taxonomy selection in editor
- Display related custom taxonomy posts in sidebar
- WordPress subpages to custom post types
- Different rewrite rules for taxonomies and cp in multisite?
- Permalinks: custom structure for taxonomy – tags?
- count results in search page based on custom category
- Custom permalink with child taxonomy terms