how can i add class or span tag at sprintf?

Actaully using esc_html won’t help because it will escape any html character, so you have to depend on wp_kses so you can specify the accepted tags and there attributes, so no need then to escape the output. but you have to escape the values comming from DB, which in you case $average_rating. so your can … Read more

Control page content visibility based on URL parameter

You can use add_shortcode() to register custom Shortcodes for restricting access to certain parts of the post content. And here’s a working example, with specific to your case: function my_rp_shortcode( $atts = [], $content=””, $tag = ” ) { if ( ‘if-rp’ === $tag ) { // Return $content if the URL query string has … Read more

Why my loop isn’t working? [closed]

I’m not 100% sure what you’re trying to do with this. Out of the Box, WordPres allows you to set your home page as either a static page, or a blog. If you choose blog, it will automatically output title and content for you. If you’re trying to customize a static home page, then you’ll … Read more

Get data from PHP to JavaScript to set position of each post on front page

You could output them as inline CSS custom properties instead of left/top, and then use those to set the position in either CSS or Javascript. PHP: <a class=”project” href=”https://wordpress.stackexchange.com/questions/345335/<?php the_permalink(); ?>” style=”—-x-position: <?php the_field(‘x’); ?>; —-y-position: <?php the_field(‘y’); ?>;'”> <p><?php the_field(“title”); ?></p> </a> CSS: .project { top: var(—-x-position); left: var(—-y-position); /* or CSS grid: */ … Read more

User Meta Value not echoing despite Var_Dump Showing correct string

The $havemeta variable isn’t defined inside your shopping_location_text() function, so it isn’t available for use there. For a quick fix (or for testing/toying) you can move your code inside the function, like this: add_action( ‘woocommerce_before_main_content’, ‘shopping_location_text’, 10 ); function shopping_location_text() { global $current_user; get_currentuserinfo(); // wordpress global variable to fetch logged in user info $userID … Read more

Capture form data in one function and use it in another function (same file)

You could use WordPress Transients to temporarily set a variable in the WP database with one function, and get that variable with another function. function setPrice(){ $myPrice = $_POST[‘price’]; set_transient( ‘ex1_temp_price’, $myPrice, 28800 ); // Site Transient } // this function can be kicked off the shortcoe, within the transient timeout function use_price(){ $price = … Read more

Where can I find the inline-css of my theme header?

That part of the page layout is most often inside of the header.php file in your theme root folder. But before you edit that file directly, a few advices: Do you use a child theme? If not, or you are not sure, than it is not advised to edit that file directly, because when the … Read more