Passing attributes to shortcode dynamically

Not quite like that, but you can achieve the same result if you use a pre-defined value or argument in your shortcode to act as a “flag”: [authoorsposts author=”post”] …then in your handler: function wpse_209684_author( $atts ) { if ( ! empty( $atts[‘author’] ) ) { $author = $atts[‘author’]; if ( $author === ‘post’ ) … Read more

Simple contact form with field validation

You don’t have any validation mechanism. Your logic should be somewhat along those lines Submit form Check submitted fields ($_POST) against expected values If all looks good send If something is not as expected, log error ( you can use WP_Error() ) and rebuild form showing error message (and maybe repopulating fields with previous “good” … Read more

How to add Shortcode (font awesome) in widget title?

I checked your code in my install. It works, except that you made a typo (missing backslash): [icon]cog[/icon] Few notes: You must make sure to enqueue the Font Awsesome stylesheet. You must close the shortcode, like: [icon]cog[/icon] Remember to escape the class name with esc_attr(). Another shortcode idea: [fa icon=”cog”]

How can i list custom post type categories?

This will list the 3 most recent posts from the post type us_portfolio. <?php $args = array( ‘posts_per_page’ => 3, ‘post_type’ => ‘us_portfolio’ ); $custom_query = new WP_Query($args); while ($custom_query->have_posts()) : $custom_query->the_post(); ?> <div class=”image bg-image” style=”background-image: url(‘<?php the_post_thumbnail_url(‘full’); ?>’)”></div> <?php the_category(); ?> <h3> <a title=”<?php the_title(); ?>” href=”https://wordpress.stackexchange.com/questions/289627/<?php the_permalink(); ?>”> <?php the_title(); ?> </a> … Read more

Splitting Shortcode Attributes not working

The var_dump() before using shortcode_atts() reveals the problem. Lets look at that output in a more readable format: array(5) { [0] => string(42) “phonePrefix=”0581″,phoneFlatOption=”true”,” [1]=> string(21) “accessModeDsl=”true”,” [2]=> string(24) “accessModeCable=”false”,” [3]=> string(22) “accessModeLte=”false”,” [“accessmodesat”]=> string(5) “false” } As you can see, the attributes are not being parsed correctly. Instead of ‘attribute’ => ‘value’ you’re getting … Read more

If numberposts = -1 offset won’t work

This problem has pretty simple explanation 😉 All you need to do is to take a look at Codex page for WP_Query and read about offset parameter: offset (int) – number of post to displace or pass over. Warning: Setting the offset parameter overrides/ignores the paged parameter and breaks pagination (Click here for a workaround). … Read more