- You enter second parameter in add shorcode is incorrect,you missing callable function in parameter.
- Like below this add_shortcode with parameter.
add_shortcode( string $tag, callable $callback );
Code :
function cpt_content_func($atts){
$post="";
$content="";
extract( shortcode_atts( array(
'slug' => null,
), $atts ) );
$args = array(
'post_type' => 'location',
'posts_per_page' => 1,
'post_name__in' => $atts['slug'] );
$post = get_posts( $args );
if ( !empty( $post ) ) {
$content = $post[0]->post_content;
}
return $content;
}
add_shortcode('stefan_location','cpt_content_func');
Related Posts:
- Is there a action hook for the “Empty Trash” button?
- Add a checkbox to post screen that adds a class to the title
- delete post also attachments
- Attach pdf file to custom post type
- Specific loop in Shortcode
- Navigation link to specific user page
- How to edit wordpress RSS feed to show post title only
- Add custom field to category of custom post type
- What Can I Use To Add A Custom Button Between Publish button and Move To Trash?
- Add custom fields to post programmatically
- How to create shortcode to show the 2 latest posts
- user contributed content as custom post types
- Remove custom posts that match taxonomy value
- Custom Theme Want To Remove One Category From All Displays
- Is it possible to have two different previews of a post (ie. two templates for one post)?
- Remove Shortcode […] from Blog Preview
- Filter Posts By Tag
- Post Type Label Name
- wp_query ‘s’ parameter does not work with custom post type
- Display a post by ID attribute with shortcode
- Blog Posts in Custom Menu
- How to display data in archive page?
- Set terms in a custom post
- Display posts styled exactly like default posts
- Move first half of posts to one parent page, second half to the other page
- Custom Post Type – Category Rewrite – Remove Rewrite from Sitemap
- CPT archive redirects to single post
- Prevent Delete Attachment by URL or When Submit
- How can i limit the number of posts created per category?
- Turn On Comments On Custom Post Types in Directory Theme
- Responsive images with custom image size
- Duplicate Custom Post Type and Taxonomy Slug
- display-posts shortcode attributes have no effect
- Shortcode and whitespace formatting problem
- Take a received feedback item, turn it into a post
- Calling Different Custom Post Timestamps in a table
- How to allow visitors to filter posts by multiple taxonomies
- How to include my own css in post
- “about us”, ” contact” sections should be article(post) or page in the simple small Business website?
- a little direction on custom post type
- disable Tab post on nav-menus page (Admin)
- Best Way to Add UnEditable HTML to Posts
- How safe is it to delete old posts edits to save database space?
- Is codex right on deleting post?
- Create a custom posts page
- How come a YouTube link isn’t transformed into a shortcode inside the post content?
- How to get different Related Posts
- Deleted a user with administrator rights. Now all the data/content/images are lost. how to recover them back
- register_post_type permalink
- Custom Post Limit for homepage only without plugin?
- How to convert query sql to shortcode in wordpress?
- Inserting an example of the last 3 post on to the homepage
- Static pages not working
- Get a term each custom post type
- Post titles and thumbnails as links to custom post types?
- Adding a custom post type meta field to rss
- Help with listing current users submitted custom post type in template file
- Deleting old posts
- How To Use Custom Tax of a Post Type
- shortcode // get posts by ids
- get posts, run a custom query, and join the results
- search form for custom fields
- Search results for ACF data
- Some custom post types did not return an object
- Redirect to custom post if custom archive page has just one result?
- Multiple posts in one page
- delete post hook not being fired when deling in wordpress dashboard admin
- WordPress Delete Users from backend doesn’t work
- Is it possible to make a custom post that adds multiple pages?
- Secretly passing post ID/title etc into a shortcode form automatically to link submission to post
- Custom post styling per category?
- Shortcode: How to add custom posts?
- Hook To Get All Posts Deleted
- Meta boxes not saving
- Custom Select Query pagination not working properly
- Custom URL Structure for posts with subcategories
- Help with a function that will place a map pin for all posts
- How to show the posts list into a static page? Problems to use the loop into a static page
- Adding The Post Template Dropdown to WP-Admin
- wordpress paginate, link to the right page
- Allow users to create their own page/s
- How to use extract shortcode in loop?
- 404 for some custom taxonomy not ALL taxonomy
- Add default content to post (for specific category)
- Setting default category for display
- WordPress strips some attributes for author posts
- How to Do Custom Fields to Output a Definition List
- Display one post randomly from category on home page
- How do I add an article to specific page?
- Deleting first four characters from all Post Titles
- Deleling wordpress posts permanently still have IDs
- get value from post to sidebar
- Taxonomy Category category.php not working
- Insert Shortcode exactly at the end of the content
- Post’s arent displaying
- Can I get custom post items in select box (dropdown)
- How to have 2 posting pages on a blog
- Simple shortcode to check if a user has commented on a certain post
- Notify/check if the content of a custom gutenberg block has changed on save_post
- How to use shortcode to get the second to newest post?