Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma

What you’re asking is a generic PHP/programming question, and this: “It links all terms to the last term link only“, is because your code clearly is attaching the link (i.e. the last value assigned to $term_link) to the entire list ($entry_terms), i.e. echo ‘<a href=”‘ . esc_url( $term_link ) . ‘”>’ . $entry_terms . ‘</a>’. … Read more

How to get an attachment id from a filename

I worked this out eventually by tracing through the code for get_attached_file() to see where it was getting the filename from, and reverse engineered the following: function get_attachment_id_by_filename($filename) { global $wpdb; $sql = $wpdb->prepare(“SELECT * FROM $wpdb->posts WHERE post_type=”attachment” and guid like %s order by post_date desc”, “%$filename”); $attachments = $wpdb->get_results($sql, OBJECT); return $attachments[0]->ID ?? … Read more

Add php code to wp_print_scripts?

You can use admin_footer or admin_head like below. This code only run on admin. You can also use for frontend by using wp_head or wp_footer function shapeSpace_print_scripts() { $block_yt_url=”test”; ?> <script> jQuery(document).ready(function ($) { let $yt_url = false; $(document).on( “click”, ‘#yt_run .acf-button-group’, function() { $(“.editor-post-publish-button__button”).hide(); $(“.acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666”).css({‘height’:’inherit’,’padding’:’16px 20px’,’overflow’:’inherit’}); $(“.acf-block-body div div.acf-block-fields.acf-fields div.acf-field.acf-field-text.acf-field-6260f423f1666”).val(<?php echo … Read more

I want to display latest post in marquee [closed]

You are using a local loop, so template functions won’t behave as expected without a $post parameter: <marquee> <?php $latest = get_posts(‘numberposts=5&cat=13’); foreach( $latest as $_post ) : ?> <a href=”<?php the_permalink( $_post ); ?>”><?= get_the_title( $_post ); ?></a> &nbsp; &nbsp; <?php endforeach; ?> </marquee>

Reset postdata not working on WP_Query in functions.php

You don’t need to modify the global current post, just use the get_posts() function instead of WP_Query(). function get_root_project_value( $meta_key ) { if ( empty( $meta_key ) ){ return false; } $args = array( ‘post_type’ => ‘slug’, ‘meta_query’ => array( array( ‘key’ => ‘project_is_root_project’, ‘value’ => ‘1’, ), ), ‘posts_per_page’ => 1, // If you … Read more

How to echo the value of an array element using a function via a shortcode

I do not understand this response unfortunately. I don’t know how to take this, and turn it into working code. What I meant by that response, is that you would be using a shortcode that looks like these in your posts: [print-price key=”price1″] [print-price key=”price2″] [print-price key=”foo-bar”] Where key is an attribute for the shortcode … Read more

Update users custom profile fields

You have specified the value of the <textarea> in a value attribute, but for a <textarea> you must put it between the two tags: <textarea rows=”10″ cols=”60″ name=”adsense_336″ id=”adsense_336″ class=”regular-text” ><?php echo esc_attr( get_the_author_meta( ‘adsense_336’, $user->ID ) ); ?></textarea>