Best Method to Switch Between Terms (Custom Taxonomy)

If I am reading your code and description correctly, you can simplify that to: $taxonomy = ‘delivery_option’; $do = get_the_terms($post->ID,$taxonomy); if (!empty($do) && !is_wp_error($do)) { $do = array_shift($do); // assuming a single value as per the description. $term = str_replace(‘-delivery’,”,$do->slug); get_template_part(‘includes/sidebar-part’,$term); } else { echo ‘<p>No custom include!</p>’; } Note, I used WordPress’s get_template_part() instead … Read more

Custom metabox fields not saving when limited to a certain CPT

SOLVED!! There was a separate check for CPT needed for the saving to work. So the conditional code now stands at: function set_options() { parent::set_options(); global $pagenow; if ( isset( $_GET[‘post_type’] ) && $_GET[‘post_type’] == ‘session’ && ‘post-new.php’ == $pagenow || isset( $_GET[‘post’] ) && ‘session’ == get_post_type( $_GET[‘post’] ) && ‘post.php’ == $pagenow || … Read more

showing tag beside catagory

Paste this code along side the code given by you I have not tested the code but it should do the trick… where you used this [blog1 items=1 cat=op-ed] replace this with this [blogtag items=1 tag=china] <?php $queried_object = get_queried_object(); $term = $queried_object->name; add_shortcode(“blogtag”, “blog_tag”); function blog_tag($atts, $content) { extract(shortcode_atts(array( “items” => 4, “tag” => … Read more

Search Page: activate html code if the tag is on the page

This is completely untested but I believe you would want something along these lines: <?php if( $loop->have_posts() ): while ( $loop->have_posts() ): $loop->the_post(); // Do stuff for results echo ‘<h2>’ . the_title() . ‘</h2>’; // Check for tag if(has_tag($tag) { output HTML if true } endwhile; else: echo “No Results!”; endif; ?>

Conditional tags returning different results for different areas on a page?

I may have misinterpreted what you are asking here but you don’t need to do this using pre_get_posts(). Instead you could either add this to your functions file: function output_page_type() { global $post; $pagename = $post->post_name; return $pagename; } and then on the relevant page echo output_page_type(); to get the page title. Or you could … Read more

Show all tags NOT applied to post

if i have understood your question, you want all tags from a taxonomy not applied to your post? maybe you can use get_terms(‘your_custom_taxonomy’) to get all of your tags, and parse/diff to your current post tags to get all tags not applied to your post https://developer.wordpress.org/reference/functions/get_terms/ or maybe try to use a filter like list_term_exclusions … Read more

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