is there a benefit in using a constant over get_stylesheet_directory_uri?

You can read up the source code of theme.php where get_stylesheet_directory_uri() is defined, inside you’ll see a str_replace() wich is consuming additional resources on each request. The best way to avoid this is to define a variable or constant that contains the path. In that case it is only called once. https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/theme.php#L0

Adding logo to WordPress header

It says right there in the code: <?php // to use a image just replace the bloginfo(‘name’) with your img src and remove the surrounding <p> ?> So just replace this line below that comment: <p id=”logo” class=”h1″ itemscope itemtype=”http://schema.org/Organization”><a href=”https://wordpress.stackexchange.com/questions/227227/<?php echo home_url(); ?>” rel=”nofollow”><?php bloginfo(”); ?></a></p> with this: <p id=”logo” class=”h1″ itemscope itemtype=”http://schema.org/Organization”><a href=”https://wordpress.stackexchange.com/questions/227227/<?php … Read more

post thumbnail, conditions, else wont work

Thanks everyone for all the help! I really appreciate it. I was able to make it work by removing [0] in $imgsrc = $img[0]; and using custom_get_meta() like: $img = post_movie_get_meta(‘featured_img’) and: $img = post_movie_get_meta(‘backdrop_img’)

Security for data obtained from the database

Well, it depends on the context. Usually we don’t need to protect data for only showing it in frontend. But the best practice is, always escape or validate data, no matter where they comes from. Like for your case you can do that like below- <label><?php echo esc_html( $data[‘title’] ); ?></label> <input type=”text” value=” <?php … Read more

How do I create my own .php file with a code part and echo it on different pages?

There’s a fundamental misunderstanding here about how partials/templates that aren’t full pages/template fragments in WP work. get_* is not how files are loaded, and get_header and get_footer are special cases for legacy reasons, kept for conventions sake. They’re actually equivalent to: get_template_part( ‘header’ ); get_template_part( ‘footer’ ); But with some additional filters and checks so … Read more

Remove author link wherever author’s name is display

You have actually two problems to solve here: The first one is to remove the HTML link, which you are trying to achieve right now. As you read in the comments, it depends on your theme. You could find it looking for the exact HTML displayed around the author name (CSS classes etc), and then … Read more

class_exists returns different values [closed]

In PHP the files are parsed before they are executed, so function and class definitions are ‘hoisted’ so that they are defined at the beginning of execution, regardless of where they are defined. This doesn’t happen when they are conditionally defined, as conditions aren’t evaluated until execution. This, from the PHP manual, was all I … Read more