how to create custom post type with dynamic category_name using shortcode

The arguments for your myCPT() function are incorrect. Callbacks used for add_shortcode() received two arguments, in this order: An array that contains the parameters used with the shortcode. The that is between the opening and closing shortcode, if supported. You code is assigning the attributes to $query (and then overwriting them), and trying to get … Read more

Line breaks inside shortcode variable

You could try using the enclosing form to write the shortcode and make use of the $content returned variable. You need to declare you short code function with the extra parameter: function transciptor( $atts=””, $content ) { and then write your shortcode as: [transcript] place the value that will be passed to $content here [/transcript] … Read more

Shortcode Always Displays Default Attribute Value

The quotes in the shortcode call were not standard (despite them looking so). Replacing the old double quote characters with typed-into-notepad, copied, and pasted new quotes in the theme editor resolved the problems. Thanks to @WebElaine and @vancoder for the help!

Shortcode not staying inside div tag

Maybe your form has a float property. So just add overflow hidden to parent div. Take a look here: https://codepen.io/zecka/pen/jObvbmG your code can be like that: <div style=”border: 3px solid green; margin-top: 1em; height: auto; overflow: hidden”> <h2>Blog notifications</h2> <?php echo do_shortcode(‘[forminator_form id=”9979″]’); ?> </div>

How to transform WordPress user role code to WP shortcode?

You can add a parameter to your shortcode function and use this value to check if the user is allowed to view the content: function func_check_user_role( $atts, $content = null ) { $user = wp_get_current_user(); $user_role = $atts[‘role’]; $allowed_roles = []; array_push($allowed_roles , $user_role); if ( is_user_logged_in() && array_intersect($allowed_roles, $user->roles ) ) { return $content; … Read more