Everything’s possible, if you take the right approach.
What I’ve interpreted from your question is, that you want an specific shortcode to be added to your content when the post is in a special category. What you can do is to hook into the_content
filter and add a shortcode, if the post is in a particular category.
add_filter( 'the_content', 'wpse314950_add_shortcode' );
function wpse314950_add_shortcode( $content ){
global $post;
// Check if this particular post has that category
if ( has_category( 'my_category', $post ) ) {
$content .= do_shortcode( '[some-shortcode arg_1="123" arg_2="xyz"]' );
}
}
There might also be more approaches, such as:
- Adding a shortcode in the content automatically (using JS or jQuery)
when the author chooses a category - Adding the shortcode to every post and then stripping it out on other categories
Related Posts:
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Display a list of random terms from custom taxonomy with shortcode
- Solution to render Shortcodes in Admin Editor
- Use AJAX in shortcode
- Display random categories on the front page (Finding and Editing Theme Functions)
- Include PHP file in Content using [shortcode]
- Shortcode producing headers already sent error
- How to add attributes to a shortcode
- How to display random users with avatars
- How to add classes to images based on their categories?
- current_cat_ancestor Alternatives
- Enabling shortcodes for custom fields
- Add body class of category parent
- How to use get_media_embedded_in_content function
- Can shortcodes contain conditional statements? Even without them my shortcode renders blank page
- Shortcode with parameters inside parameters
- Creating a table from shortcode avoiding wpautop for each row
- Counting number of posts in a category and its sub categories and displaying result using shortcode
- Stripping shortcode from custom excerpt function
- how to create shortcode in wordpress
- What is wrong with this Shortcode? I get it in a wrong place inside the content
- Php string not working in WordPress Functions.php (trying to fetch 1st category for each blog that post appears in the sidebar)
- Add class to Categories Widget
- Display random text from a file with the WP built-in AJAX API
- How to Acheive the custom woocommerce category template
- Set first oembed in post to a global variable or function
- Formatting post content to exclude gallery
- Remove images from get_the_excerpt
- Shortcode with custom content attribute?
- Problem with extract() with custom shortcode
- Shortcode to insert menu in page body?
- How to add a rel attribute to images that contains their categories?
- How to set child post categories to parent post categories when updating parent post?
- Using locate-template & shortcodes doesn’t appear to work
- Displaying a random user with a shortcode
- Assign category using custom field?
- Passing HTML in WordPress Shortcode arguments
- Adding body class when post contains a specific shortcode
- How To Get WordPress Categories Link List?
- Function to show only first instance of shortcode
- Display a text message if the shortcode is found?
- Changing post category from dropdown
- Manipulate Output of wp_list_something: select menu instead of li’s
- Make Categories a Dropdown Menu in Media Library
- creating shortcode to pull json array
- Custom Shortcode, functions PHP WP_Query loop
- Programmatically Create Category and sub Category
- Pass Shortcode Attribute to footer Script
- Super simple shortcode not working
- Attach parent category template to all subcategories
- Detect Safari desktop browser and include the detection in a shortcode
- My simple custom shortcode is not longer working (possibly due to upgrade to WordPress 4.4 ?)
- Display gallery on top before content
- List child pages of specific page using shortcode
- exclude a category from a search on a specific page
- Get the category name outside of the loop in category.php
- Is it possible to change any of the HTML/URL returned from the_category()
- How to extract the variables out from “add_shortcode” function?
- Custom HTML in specific category single page and its descendant categories
- Display first name of logged in user?
- How to get specified parent page title in my function
- Unset Category if other Category is unset during post transition
- WordPress shortcode attributes for database SELECT?
- Shortcode pagination not advancing
- create shortcode to list users with specific meta key value
- Variable if post is sticky in functions.php
- Select pages by category
- Having issues with a foreach inside of a shortcode with ACF gallery
- Shortcode inserts paragraphs before and after executing shortcode
- Display post shortcode content in the sidebar?
- Show Primary Category first when I display post categories
- How do I hide or remove ‘Category’ from wordpress breadcrumbs
- Ordering posts by publish date not working?
- How to get the index number of the posts?
- Using shortcode content with nested shortcode
- How can I make a widget shortcode to control all the widgets?
- Custom shortcodes not inserting into visual composer columns
- How to filter $content in shortcode function
- Create a custom taxonomy that will be used to create and filter markers in a Google Map
- Setting youtube size in functions.php
- Categories as main menu items and subcategories as nested lists
- Adding a colorbutton in tinymce dialog with current api
- Passing variable as add_shortcode argument
- Display gallery on bottom after content
- Add button to kitchen sink toggle
- Excerpts are not displayed by a shortcode on category pages
- Redirect to another page using contact form 7? [closed]
- WordPress Shortcode function display outside of widget
- Get category URL for current post
- check if the user is owner of current page
- Need help “sanitizing” a custom function that pulls category slug into body class
- shortcode help require
- allow only one post in specific category
- Optimizing a WordPress site
- Help With Creating Shortcode
- Use html inside shortcode function
- How to obtain the recent posts without their content in an efficient way?
- Setting a default text for excerpts of a particular category
- Running script based on Category
- Remove a category from a post when saving a new post