Display post by click on the link

You can achieve this by using Query String. First you have to make template in your theme folder. To show post list on right side and description of post on left side I am using div with class name right and left (specify your desires css properties in those classes). To show list of posts … Read more

wp_update_post creating revisions instead of updating the post

check: https://codex.wordpress.org/Function_Reference/wp_update_post Make sure not to create an infinite loop. <?php function my_function( $post_id ){ if ( ! wp_is_post_revision( $post_id ) ){ // unhook this function so it doesn’t loop infinitely remove_action(‘save_post’, ‘my_function’); // update the post, which calls save_post again wp_update_post( $my_args ); // re-hook this function add_action(‘save_post’, ‘my_function’); } } add_action(‘save_post’, ‘my_function’); ?> … Read more

wp_set_object_terms NOT working on CPT, but wp_set_post_terms does

After much trial and error, I have found a solution that will allow wp_set_object_terms to be used. Despite already checking if my strings were integers, apparently I needed to convert the array explicitly as well. So I changed this: $customtax = $customtaxarray; to this: $customtax = array_map(‘intval’,$customtaxarray); and suddenly wp_set_object_terms now works. That does not … Read more

Plugin custom post template; without overriding all posts

Not sure if there’s a better way to do it, but you can use the theme_<post type>_templates filter to add your custom template to the “Template” dropdown, and then use the template_include filter to ensure the correct file is loaded. So something like this should work: add_filter( ‘template_include’, ‘my_events_template_include’ ); function my_events_template_include( $template ) { … Read more

Changing Post Tag Color Based On Post Count

Here you go. I just added a class using $tag->count. Tested and works. <div class=”container”> <?php $tags = get_tags(array( ‘hide_empty’ => false, ‘count’ => true )); foreach ($tags as $tag) :?> <a class=”count-<?php echo $tag->count; ?>” href=”https://wordpress.stackexchange.com/questions/324587/<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>” title=”<?php echo esc_attr( $tag->name ); ?>”><?php echo esc_html( $tag->name ); ?></a> … Read more

How to enable custom Shortcodes in Post Category Description? [duplicate]

I found the answer to my own question. add_filter( ‘term_description’, ‘shortcode_unautop’ ); add_filter( ‘term_description’, ‘do_shortcode’ ); remove_filter( ‘pre_term_description’, ‘wp_filter_kses’ ); I just added those line of codes into the Child theme’s function.php. Thanks to this post: How to get a shortcode working in category description