How do I add functionality to images?

If you want to append HTML to images, you want to look inside the template files. Search for something like the_post_thumbnail function, and add your HTML right after the closing </a> tag (if there is one). You’d then need to style it with CSS so that it’s only visible upon hovering the image. For example, … Read more

is_preview() always return false

is_preview() should return true is it is a preview. Did you try the following on the page.php? if(is_preview()){ echo “preview” }else{ echo “no preview” } to check if the is_preview() function is working? EDIT2: You could work your way around it and check for: if($_GET[‘preview’] == true){}

Rename file after title , one small problem

Use get_the_title() since you’re already being passed a post ID. function rename_attacment( $post_ID ) { $post = get_post( $post_ID ); $file = get_attached_file( $post_ID ); $path = pathinfo( $file ); //dirname = File Path //basename = Filename.Extension //extension = Extension //filename = Filename $newfilename = get_the_title( $post_ID ); $newfile = $path[‘dirname’] . “https://wordpress.stackexchange.com/” . $newfilename … Read more

Why functions metaboxes is causing White Screen in Admin [closed]

Finally I found the solution in codex…. Interpreting the Error Message: If the error message states: Warning: Cannot modify header information – headers already sent by (output started at /path/blog/wp-config.php:34) in /path/blog/wp-login.php on line 42, then the problem is at line #34 of wp-config.php, not line #42 of wp-login.php. In this scenario, line #42 of … Read more

How to string lines from the_content() hook in WordPress?

I don’t know any other way There is a much, much better way to do this – custom fields. As per these instructions in the custom fields docs, let’s say you use the field name iframe_url: <iframe src=”https://wordpress.stackexchange.com/questions/230707/<?php echo esc_url( get_post_meta( $post->ID,”iframe_url’, true ) ?>” width=”960″ height=”540″ frameborder=”0″ allowfullscreen=”allowfullscreen”></iframe> <?php the_content() ?> See how much … Read more

How do grab the main loop, with conditions, and output via shortcodes

Are you sure you want to do this in this manner? Normally a section like this might be written to the page template somehow and not called via the content editor. That being said, this should do what you need: add_shortcode( ‘show_xyz_news’, ‘xyz_news_query’ ); function xyz_news_query() { $args = array( ‘posts_per_page’ => 3, ‘category_name’ => … Read more

display php code in header using wp_head()

As per my understanding you wish to print content from get_option below . For that please write below code to funcitons.php file: function my_facebook_tags() { return $options = get_option(“p2h_theme_options”); } And below code within your header file below to wp_head() write: <?php echo my_facebook_tags();?> Hope this will resolve the issue for you! EDITED: Try the … Read more