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
- Custom Taxonomy as checkbox or dropdown
- What are the differences between custom post type and custom page templates?
- WP insert post and custom taxonomy
- WP_List_Table Inside Metabox Not Working on Submit
- How to filter post data with AJAX on page?
- Custom permalinks
- Query multiple taxonomy in Custom Post Type
- automatically create taxonomy with same name as post title
- Separate Custom Post Type Taxonomy by Comma
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Get child terms of current term of the current post
- Allow duplicate slugs for posts on Custom post type in different categories/taxonomy?
- Assign category to front end post
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- WordPress import not importing custom taxonomy
- Is there any performance consideration when using Custom Post Types?
- Ordering Custom Post Types with WP_Query
- Taxonomy structure of Sport site
- Custom post type custom taxonomy archive page name
- How can I move a custom taxonomy and its data from one post type to another?
- Permalinks not working for custom taxonomy on custom post type
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Custom taxonomy in custom post RSS feed
- How to display product subcategories into my custom post type single page
- wp_query check if integer exists in custom field’s array
- Template for custom post with custom taxonomy
- How can I set taxonomy programmatically
- Return the latest post from a custom Taxonomy and Post Type
- Don’t know how to show custom taxonomies from a custom post_type
- list taxonomies from a custom post type
- WordPress custom taxonomy, posts urls
- WordPress loop: Show only a Custom Post Type Taxononmy TERM
- Import data from CSV with custom taxomony empty
- Custom Post Type Loop with Query Var
- Full Custom Post Type List Organised by two Taxonomies
- URL rewriting for CTP assigned entity
- Template for all categories of a custom post type?
- How to group posts and get a mixed posts and groups view?
- in_category for custom post types
- Control content before and after custom post type loop
- Listing all slugs?
- post_type_link Filter – Too Few Arguments
- My custom taxonomy is only displaying 1 of 3 terms
- Show categories of custom post type and not all posts
- Reusable metabox backend and frontend
- Archive page for custom post type and custom taxonomy
- How to display posttypes and taxonomy in standard posts, not in a separate label?
- Loop for custom-post-type comparing taxonomy terms for “related” posts?
- Creating custom post type and taxonomy archives and pretty URLs
- Should i use custom post type for a custom footer?
- Show 10 newest post for each value of a custom taxonomy
- Display the link of a custom taxonomy
- Custom taxonomy: on the taxonomy term page show other taxonomy terms
- Error 404 change permalink term custom term taxonomy
- Custom post categories are not displaying on the page
- get_posts wont produce a list of custom type from a given category [duplicate]
- Display Custom Field or Custom Taxonomy in front page /post/product
- CPT tags not showing when editing post
- Some posts not displaying by taxonomy term
- WP_Query for custom taxonomies showing posts from non-specified terms?
- How to add independent “Tags” to Custom Post Type?
- Display custom tax in “while” loop
- Show posts under a selected custom taxonomy term
- Custom taxanomy and custom post type – pagination leads to 404
- Getting all custom post taxonomies and exhibiting only part of them
- Linking Taxonomies
- Get posts under custom taxonomy and custom post type
- Flush rewrite rules when new cpt is registred
- Shortcode in excerpt
- Custome post type “tags” pick default archive instead of custom post type archive
- How do I retrieve the title of a term of a custom post type with custom taxonomies?
- Show custom taxonomy not in submenu
- Custom post type AND custom taxonomy are not connected
- Single page archive – get coresponding taxonomy and terms
- How to assign custom post template to its custom taxonomy terms
- Excluding top level from taxonomy and post loop
- Custom Post Type and Custom Taxonomy not connected
- Displaying custom post types with taxonomy
- Get a list of categories ids
- How to Associate Posts with Pages
- Using one custom taxonomy.php for two custom taxonomies?
- Add taxonomy to custom post type archive
- Custom taxonomy archive not showing posts of certain child taxonomies
- Custom posts and custom taxonomies for many products and categories?
- How to retreive terms associated with a custom post type?
- How do i get the taxonomy term name on the CPT archive page?
- Create taxonomy from Custom Post Type
- Show custom category archive as front page and remove taxonomy slug from urls