Display post by select it from a dropdown menu

To fix this issue, move the closing curly brace } for the foreach loop before the add_shortcode function, like this: function form_creation(){ ?> <select name=”page_id” id=”page_id”> <?php global $post; $args = array(‘cat’=>19); $posts = get_posts($args); foreach( $posts as $post ) : setup_postdata($post); ?> <option value=”<? echo $post->ID; ?>”><?php the_title(); ?></option> <?php endforeach; ?> <!– Move … Read more

Icon not shown in Dropdown menus in Twenty Seventeen Theme

It’s not images, its fontawesome icons, and the fontawesome library is not being called. so you can add the below code to your theme functions.php add_action( ‘wp_enqueue_scripts’, ‘enqueue_load_fa’ ); function enqueue_load_fa() { wp_enqueue_style( ‘load-fa’, ‘https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css’ ); } thats how the current icons for the menus will be showing.

Dropdown Value from DB Entry

You’re not actually outputting the selected attribute into the <option> tag. Look at your printf() format: ‘<option value=”%u”>%s</option>’ %u is there for the month’s number value, and %s is there for month’s name, but you’re not including the last argument from the result of selected(). Your printf() needs to look like this: printf( ‘<option value=”%u” … Read more

How to elect position of new item output in a dropdown when using add_filter

You can achieve this by using the array_splice() function in conjunction with array_merge(). Here is an example: function add_new_job_application_status( $statuses ) { return array_merge( array_splice( $statuses, 0, 1 ), array( ‘example’ => _x( ‘Example’, ‘job_application’, ‘wp-job-manager- applications’ ) ), array_splice( $statuses, 1, -1 ) ); } add_filter( ‘job_application_statuses’, ‘add_new_job_application_status’ ); This function takes the first … Read more