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

Filter oembeds tags to modify iframe attributes

I was able to solve the the CORS issue by using this snippet which now allows this iFrame to allow-same-origin or runs scripts inside this domain. function oembed_iframe_overrides($html, $url, $attr) { if ( strpos( $html, “<iframe” ) !== false ) { return str_replace(‘<iframe class=”wp-embedded-content” sandbox=”allow-scripts allow-same-origin”‘, ‘<iframe class=”wp-embedded-content” sandbox’, $html); } else { return $html; … Read more

Can’t change a label in woocommerce with the normal filter

You have to use the woocommerce_default_address_fields hook: add_filter( ‘woocommerce_default_address_fields’ , ‘wpse_120741_wc_def_state_label’ ); function wpse_120741_wc_def_state_label( $address_fields ) { $address_fields[‘state’][‘label’] = ‘County’; return $address_fields; } This (and more) is described at the woocommerce docs: Customizing checkout fields using actions and filters, so read your stuff next time thoroughly… 😉 Edit: Above code isn’t working for all cases, … Read more

Problem getting single_template filter to work – I want to serve a different single.php file for posts in a certain category

The problem was that the remove_filter function wasn’t working. Apparently this is not uncommon from what I’ve read. I tried testing it with different priorities (1, 9, 20, 999), but there was no difference. So my filter in the child theme and the filter I was trying to remove from the parent theme both had … Read more

Setting title using wp_title filter

Since wp_title() is usually called from the header.php file of your theme, then it runs on every page of your WordPress (frontend usually). So place the filter hook and function in your theme’s functions.php file, and just check if it’s a blog post before you change the title. Something like this: add_filter(‘wp_title’, ‘filter_pagetitle’); function filter_pagetitle($title) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)