How to Get The Taxonomy Term in Custom Post Type Loop Inside a Wp Query

while ( $loop->have_posts() ) : $loop->the_post(); //Edit Width post type $categories = get_the_terms(get_the_ID(), ‘services’); $separator=”, “; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { echo ‘<a class=”cat_item” href=”‘ . esc_url( get_category_link( $category->term_id ) ) . ‘” alt=”‘ . esc_attr( sprintf( __( ‘%s’, ‘your-themes’ ), $category->name ) ) . ‘”>’ … Read more

If do_shortcode is blank, return some message

From several version of WordPress, it’s better to use https://developer.wordpress.org/reference/functions/apply_shortcodes/ io do_shortcode. That said you can surely do something using has_shortcode() https://developer.wordpress.org/reference/functions/has_shortcode/

Check if MemberPress exists before add_action call

Since I do not have access to the plugin to confirm I’ll use generic info and updated my answer since I was using the demo they had in their docs. This works in the functions file or on the frontend. // check for plugin using plugin name if(in_array(‘plugin-directory/plugin-file.php’, apply_filters(‘active_plugins’, get_option(‘active_plugins’)))){ //whatever you need goes here. … Read more

WordPress Set A Static Page/Template For All Sub-Pages

Okay so I have resolved this by combining several different wordpress functionalities: Catches the template include conditionally add_filter( ‘template_include’, ‘…’ );, in my case based on a regex match of the expected URI pattern locate_template(‘example-template.php’) to then resolve my (essentially) static template A query within my example-template.php that externally retrieves the resource This must handle … Read more

How to change Akismet commenter privacy notice?

Aha, I finally got it working: <?php /* Plugin Name: Akismet Better Privacy Notice Description: Inform users about what’s actually happening with their data */ add_filter ( ‘akismet_comment_form_privacy_notice_markup’, ‘better_display_comment_form_privacy_notice’ ); function better_display_comment_form_privacy_notice() { echo sprintf( ‘<p class=”akismet_comment_form_privacy_notice”>’ . ‘Warning: This site uses Akismet to filter spam.’ . ‘ Until or unless I can find a … Read more

WordPress get id from json data with json_decode()

json_encode takes an array/object and turns it into a JSON string. json_decode takes a JSON string and turns it into a PHP array/object/etc With this in mind, we can see some critical mistakes are made in the code, caused by muddling up the two. You’re taking a string of JSON and JSON encoding it, aka … Read more