How to add data- attribute to tag

There are two ways to solve this. The first one is what you are trying, but you have to print out the value you get. Like this: print get_post_meta(); I don’t recommend this for two reasons: You should keep your templates as simple as possible. Otherwise they become cluttered with fragments of business code which … Read more

How do I add a current class to the current post?

try this: <ul id=”post-list”> <?php global $post,$wp_query; $current_id = $wp_query->get_queried_object_id(); $args = array( ‘numberposts’ => 7 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li<?php if ($current_id == $post->ID) echo ‘ class=”current”‘; ?>> <a href=”https://wordpress.stackexchange.com/questions/26841/<?php the_permalink(); ?>”><?php the_title(); ?><br /><span><?php the_author(); ?></span></a> </li> <?php endforeach; ?> </ul>

WordPress RSS feed – filter RSS content by custom field value

You can try to add geo_country as an extra query variable with: /** * Add the ‘geo_country’ as a public query variable * * @param array $query_vars * @return array $query_vars */ function my_query_vars( $query_vars ) { $query_vars[] = ‘geo_country’; return $query_vars; } add_filter( ‘query_vars’, ‘my_query_vars’ ); and then setup a pre_get_posts hook to filter … Read more

4.0 remove_filter for WordPress core function not working for me

From the comments the remove_filter is called too early before the core add_filter is called. Best way to avoid this is to always remove nd add your filter at the init action add_action(‘init’,’wpse163434_init’); function wpse163434_init() { remove_filter….. add_filter….. } This way you are assure that the core had finished initializing and all the core actions … Read more