How do I get the slug of a custom taxonomy category of a post?
This shouldn’t be too hard! $my_terms = get_the_terms( $post->ID, ‘portfolio’ ); if( $my_terms && !is_wp_error( $my_terms ) ) { foreach( $my_terms as $term ) { echo $term->slug; } }
This shouldn’t be too hard! $my_terms = get_the_terms( $post->ID, ‘portfolio’ ); if( $my_terms && !is_wp_error( $my_terms ) ) { foreach( $my_terms as $term ) { echo $term->slug; } }
I built a similar feature for my personal website, that consists of a new database table, WordPress admin page and some .htaccess rewrites. Unfortunately the setup is too involved with my particular installation to be useful as a plugin, but there are plenty of URL shortener plugins available already. A quick search yields this WP … Read more
The error in the SQL statement is at the very end, SELECT * FROM c_posts WHERE id = , There is no value being supplied to check against the id column. This is most likely because you didn’t check for a blank value in the ID field before forming and executing the query. Check the … Read more
You can insert an associative array into the post_meta_field. Here is a quick little function to grab the data afterward (did not test): function grab_task_name_array($post_id) { $new_array = array(); $array = get_post_meta($post_id,’_task-name’); //do not put true as third parameter (this would return string and not array) foreach($array[0] as $key => $value) $new_array[$key] = $value; return … Read more
Chain the filters: if ( ‘include’ == $query->query_vars[‘orderby’] ) add_filter( ‘posts_orderby’, /* … */ ); And in your orderby filter use: remove_filter( current_filter(), __FUNCTION__ );
To revert from scheduled to draft without publishing immediately this works for me (WordPress 3.9.1 ) change scheduled date to yesterday OK Save as draft done
add_filter(“manage_{xxxx-xxx}_columns”, “cusotm_callback_fun02” ); is used to add the column itself to the list of columns for that post_type. add_action(“manage_posts_custom_column”, “custom_callback_fun01”); adds the actual content of the column per post.
function exclude_single_posts_home($query) { if ($query->is_home() && $query->is_main_query() && !is_admin()) { $query->set(‘post__not_in’, array(post-id)); } } add_action(‘pre_get_posts’, ‘exclude_single_posts_home’); Source: pre_get_posts
HTML language includes a special tag for displaying inline code. To apply it to your text, switch to the ‘Text’ visual editor tab and place the <code> tag before your bit of code, and the </code> tag afterwards. If you want to use the backtick ` character for highlighting code like you do on Stack … Read more
I would do this with $query->current_post and $query->post_count with $query = new WP_Query(args);. With this you may get the position and the total of posts.