Include a file that has a function in it
This was a tough one to figure out, but I finally got it to work. You have to use locate_template to build the url like so: include(locate_template(‘codesnippet.php’));
This was a tough one to figure out, but I finally got it to work. You have to use locate_template to build the url like so: include(locate_template(‘codesnippet.php’));
You could easily query all the posts with a taxquery, and loop through the results, deleting them one by one. wp_delete_post() gives you the option of moving a post to the trash, or forcing to delete it – so be careful with that. To be sure that you delete the right posts, you can create … Read more
You have multiple syntax errors in your code, see comments in below code: Code: <?php $googleplay = get_option(‘director_googleplay’); ?> <?php if( $googleplay ) : ?> // use echo not print <a href=”https://wordpress.stackexchange.com/questions/133771/<?php echo $googleplay; ?>”> // rework your src/IMAGES statement // is this a constant/variable? <img src=”<?php echo IMAGES; ?>/googleplay.png” class=” img-responsive top-buffer-5″ alt=”Image”/> // … Read more
I’m not sure if you want it like this, however, this can be achieved by CSS. .crumbs > span > span + span { margin-left: 1em; } .crumbs > span > span + span:before { content: ‘|’; /* or something else */ *display: inline; display: inline-block; margin-left: -1em; width: 1em; text-align: center; } // EDIT … Read more
You have to find out how the plugin is licensed that you are going to use. Then read the details of that licence. Usually the least to do is to mention the author and/or name of the plugin used. For reference WordPress is licensed under GPLv2 (or later). The WordPress License
You need to add it to a JS file and then enqueue it in your functions.php jQuery(document).ready(function($){ $(‘p’).wrap(‘<div class=”post-txt” />’); }); If you already have a js file, you can add it to that file and you’re done. Else, save the above snippet in a new file. Put that file in a folder called js … Read more
Firstly, there are syntax errors in your (last block of) code. And secondly, you don’t need to add any specific class at all. Just use the post ID for each post: <article id=”post-<?php the_ID(); ?>”> <div class=”post-content”> <?php if (‘excerpt’ === $gantry->get(‘blog-content’, ‘content’)) : ?> <div class=”excerpt”> <?php the_excerpt(); ?> </div> <?php else : ?> … Read more
In short, you’ll run the loop twice. The first time creating the links. The second time creating the posts. The trick is to figure out what the ID will be for the post. It needs to be something unique: We could use the slug or the post ID. <?php // I’m going to get the … Read more
This is plain PHP (logic): foreach ($existing_list as $key => $value) if (isset($existing_list[$key][$add_to_ID])) $existing_list[$key][$add_to_ID] = $note; What you did before was not update the sub-element with key 321 for each element but set the sub-element with that particular key for each element—which is in essence: update where already defined, define otherwise.
get_post_meta() should only return false under a couple of circumstances: 269 function get_metadata($meta_type, $object_id, $meta_key = ”, $single = false) { 270 if ( !$meta_type ) 271 return false; 272 273 if ( !$object_id = absint($object_id) ) 274 return false; https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/meta.php#L269 I don’t see how $meta_type could be wrong since it is hard-coded into get_post_meta(): … Read more