Is it possible to define variables in a wordpress shortcode, and then call the shortcode using a specific variable?

I think you are looking for this- function star_rating( $atts ) { $max = 5; $atts = shortcode_atts( array( ‘grade’ => $max, // default ), $atts ); $star_icons=””; $full_star = floor( $atts[‘grade’] ); for( $i=1; $i<=$full_star; $i++ ) { $star_icons .= ‘<i class=”fa fa-star”></i>’; } $half_star = 0; if( (int) $atts[‘grade’] != $atts[‘grade’] ){ $half_star … Read more

WordPress archive page showing 404 Error [duplicate]

You should mention register function in your Question. Add flush_rewrite_rules( false ); in Your custom_post_type register function. it is necessary when you are creating custom post with archive. example code: function create_my_post_type(){ register_post_type(‘MyPost’, array( ‘labels’ => array(‘name’ =>__(‘My-custom-Post’),’singular_name’ => __(‘my-post’)), ‘rewrite’ => array(‘slug’ => ‘MyPost’,’with_front’ => true), ‘public’=>true, ‘has_archive’ => true, )); flush_rewrite_rules(false); //recreate rewrite … Read more

Problem with AJAX in wordpress plugin

After Milo’s tutorship: I recommend first reading how to use AJAX in Plugins properly. – Milo yesterday and reading another questions on wp.stack, my problem was solved) Here is an examples of code from my rewritten files 1)get_state.php: ad add_action( ‘wp_ajax_ajax_object’, ‘ajax_handler’ ); add_action( ‘wp_ajax_nopriv_ajax_object’, ‘ajax_handler’ ); function ajax_handler() { global $wpdb, $results, $info, $data, … Read more

Limit Taxonomy Output in Conditional Statement

Samuel Elh correctly answered this. if ( $type === ‘portfolio’ ) { $terms = get_the_term_list( $post->ID, ‘royal_portfolio_cats’, ”, $separator ); $term_array = explode(‘,’,$terms); if ( $limit = array_slice($term_array, 0, $max = 5) ) { echo implode( “, “, $limit ); if ( count( $term_array ) > $max ) { echo “…”; } }; }

Remove dash from blog title wordpress

This is not quite trivial in general case, since it varies depending on title implementation by specific theme. The historical way has been wp_title() call in theme’s template. The newer method is hook–based Title Tag. So it is hard to say specifically without knowing/seeing code of a specific theme. This is one of the reasons … Read more