Hi I need a list of the permalinks and titles for all posts in a given custom post type.
How would I do this?
Thanks for your help
Hello, if you want to display a list of post titles and permalinks on the front-end of the site, you should use Toolset Blocks or Toolset Views to create a View of this custom post type. In the loop of that View you can use the Single Fields block to display the post title, or post title with a link, or the post URL. You can insert multiple Single Field blocks in the View's loop to display more than one piece of information about each post.
Does this answer your question, or did I misunderstand what you want to achieve?
Hi Christian,
Thanks very much for your reply.
Would it be possible to see a Views code snippet of what you describe without using Blocks .
Thanks
Yes, if you prefer to use Views you can create a loop with the following code:
[wpv-layout-start]
[wpv-items-found]
<ul class="wpv-loop js-wpv-loop">
<!-- wpv-loop-start -->
<ul class="wpv-loop js-wpv-loop">
<wpv-loop>
<li>
[wpv-post-title], [wpv-post-url]
</li>
</wpv-loop>
</ul>
<!-- wpv-loop-end -->
</ul>
[/wpv-items-found]
[wpv-no-items-found]
[/wpv-no-items-found]
[wpv-layout-end]
You can find out more about the post title and post url shortcodes in the Views Shortcode developer documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
Thanks for this Christian.
How do I limit this to just custom posts of type plant?
Thanks
In the View Editor screen Content Selection panel, you should select the "Plants" post type and deselect all other post types.
My issue is resolved now. Thank you!