Hot answers tagged

2

Use wp_get_attachment_image_src to get the image properties and URL: $logo = get_theme_mod( 'custom_logo' ); $image = wp_get_attachment_image_src( $logo , 'full' ); $image_url = $image[0]; $image_width = $image[1]; $image_height = $image[2]; Edit: Adding more information based on your comment. The URL it points to is simply made with home_url: esc_url( ...


2

Iframe content is generated by youtube itself, wordpress just requests it via oembed call. If you wish you can study wp-includes/class-oembed.php code, but that will not help you to change iframe parameters. For that you may apply embed_oembed_html filter, see https://developer.wordpress.org/reference/hooks/embed_oembed_html/. It receives iframe html code, ...


2

Change you constructor to this public function __construct($post) { $this->set_bio($post->post_content); $thumbnail = get_the_post_thumbnail_url($post->ID); $this->set_thumbnail($thumbnail); } and remove thumbnail code from init method.


2

Based on WordPress documentation for esc_attr function, it is returning a string value. So, If you need to have the integer value, you need using intval function. But, when you want to display that value or put it as part of markup, it doesn't make sense. Escape functions are useful for outputting and printing values. If you want to save a value in the ...


2

This is more general PHP than anything WordPress specific. String concatenation occurs whenever you combining two stings with the . operator. During string concatenation some basic PHP keywords will not apply and you'll need to use the shorthand equivalent instead. In this case you can use the ternary (conditional) operator $html.= '<span class="cat">...


1

The problem is you aren't saving your custom query's results. To do it your way, you would need to save the query's results to a variable, like so: $myposts = query_posts( $archive_args ); if ( $myposts->have_posts() ) : while ($myposts->have_posts()) : $myposts->the_post(); However, that's not the most efficient way. WP runs the default query in ...


1

If you're just trying to add a template within the theme, name your file single-profile.php and that will apply to all single "profile" CPTs. But you mentioned you don't want to touch the child theme. You could instead create a plugin and use a page_template filter to use your plugin's single-profile.php template instead of any of the theme templates. You ...


1

get_the_ID is a WordPress core fuction in the global namespace, so you can't make a second function called get_the_ID as it won't know which one to use. You should just call get_the_ID() without writing a new function. For your example code, you could do something like this: <div> <?php echo do_shortcode( '[svg-flag flag="' . get_post_meta( ...


1

If the data you placed at the beginning of your question is the result of your database query (I'm unsure by how your question is worded), you will want to take that query result and use the PHP function unserialize() to convert that data to an array, then you can access your data from that array. Your serialized data will become at array that looks like ...


1

Not the most elegant solution, but you can use something like this add_action('wp_footer', function() { $post = get_post(); if ($post && $post->ID == ... do your post selection here) { ?> <style> body { background-color: #fff !important; } </style> <?php } }...


1

The CSS is generated on the file inc/custom-css.php, the background color is set on line 76: $background = sanitize_hex_color_no_hash( get_theme_mod( 'background_color' ) ); So you can take advantage of the theme_mod_{$name} filter, which changes the value of the get_theme_mod($name) function, by adding this to your functions.php file: add_filter( '...


1

WP CLI is best tool out there to manage plugins/ themes through command line, instead of uploading plugins through FTP or admin panel. Once you Install WP-CLI on your machine then run below command and see magic. wp plugin install bbpress --activate Please check WP-CLI official documentation for further understanding.


1

You're checking isset( $_POST['SUBMIT'] ), but there's no field with that name. If you mean to be checking the submit button, you need to give it a name attribute with the right value: <input type='submit' name='SUBMIT' value='SUBMIT'> Now isset( $_POST['SUBMIT'] will be true, and your code will run. Also, you don't seem to be using $wpdb->prefix ...


1

You should have the desired code defined within your clearline_func function like this: function clearline_func() { //copy & paste the profile-card.php code here } add_shortcode('test', 'clearline_func'); If you need to keep the profile-card.php file and want to avoid duplicate code then you should use PHP include() to call the file as @KFish ...


1

Not sure what your test() function is meant to achieve, or if you've even defined it, but yes if you haven't defined it then it's undefined. In reference to your question: "What's the best method to include all content from profile-card.php and use that shortcode to show it?" The answer is actually in your question, i.e. the best method to include it is to ...


1

You can't enqueue because wp_loaded is too early. To enqueue scripts and styles, you need to do it on the wp_enqueue_scripts type hooks, but because your exiting on wp_loaded, none of those hooks have fired yet. Additionally, you need to have the necessary function calls in the template for it to enqueue them into, such as wp_head or wp_footer, otherwise ...


Only top voted, non community-wiki answers of a minimum length are eligible