How to use the checked() function to check for a non-empty var

Not possible. You may do both, but may not be as optimal as single line: $verify = (empty($var)) ? ‘current_value’ : $var; checked( $verify, $current ); Or you can create a custom function: function better_checked($check, $current, $echo = true) { $result=” checked=”checked””; if ( ( $check != ” && $current != ” ) && ( … Read more

Tracking the number of shortcodes for a list?

Wrap an <ol> around them and have your [resource] shortcode create an <li> for each one. Editor view: <ol> [resource name=”Resource” link=”http://foo.com”]Why I love it[/resource] [resource name=”Another Resource” link=”http://footwo.com”]Why I love this[/resource] </ol> HTML output: <ol> <li><a href=”http://foo.com”>Resource</a><p>Why I love it</p></li> <li><a href=”http://footwo.com”>Another Resource</a><p>Why I love this</p></li> </ol>

How to reference PHP in Javascript

To answer the question, no: It’s not an issue with formatting, it’s as jdm2112 explains the matter. You can, however, “send” the variable , or have it plucked from the server, either via an Ajax call as jdm2112 suggests or as set by wp_localize_script(). Which you use will likely depend on what the script does … Read more

WordPress wraps span tags into p tags

I have investigated this problem and recognized that it is not the TinyMCE fault, but the issue is caused by the the hook function wpautop instead. And tags are wrapped just before post is being displayed. So in order to fix this issue just remove the hook function like that. remove_filter( ‘the_content’, ‘wpautop’ ); This … Read more

Update to functions.php not showing in dashboard

It looks like I have solved my own problem. I’m guessing that a function like that creates a permanent change, regardless of whether the function remains in the functions.php file. So, to fix this, I just added a new function reversing this adding. Here is that function: function remove_theme_caps() { $role = get_role( ‘author’ ); … Read more

get_terms (or tax_query) for term of current post?

SOLVED This was what I was looking for and it works like a charm. function my_query_args($query_args, $grid_name) { $term_list = get_the_terms( get_the_ID(), ‘category’ )[0]->slug; if ($grid_name == ‘JTS-SINGLE’) { $query_args[‘tax_query’] = array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( $term_list ), ), ); } return $query_args; } add_filter(‘tg_wp_query_args’, ‘my_query_args’, 10, 2);

Get post format

If you’re outside the loop, pass a post ID. $format = get_post_format( $post_id ); To guard against missing formats, add a default to your template: $format = get_post_format() ? : ‘standard’; Then you can use your same IF statement: if ( $format == ‘link’ ) :

first paragraph of the_content as meta description

You can use the_excerpt() instead of the_content Reference link for filter your excerpt : show-first-paragraph Or you can also do this by callback function inside your loop using the function to modify the_content as below: function get_first_paragraph(){ global $post; $str = wpautop( get_the_content() ); $str = substr( $str, 0, strpos( $str, ‘</p>’ ) + 4 … Read more