Web Dev
WordPress: Attempt to assign property “post_content” on null
I’ve hit this error a few times. The issue is with the wp_posts table, where for some reason when exporting/importing the database/table causes some issue with multiple posts having the same IDs for multiple posts. To resolve, re-import the database, or possibly delete out all of the rows that have duplicate post Ids.
Read MoreGetting Data from Multiple .then Statements in Javascript
I always have a hard time pulling data through multiple .then statements in javascript. This method works sufficiently well. Basically, define an array/object, and then as data is collected, add content to that array. All of the collected content should be available in the final .then statement. Something like this (all the data is collected […]
Read MoreBlurry Background Images in CSS
There are a number of reasons why background image can look blurry in CSS, but recently I came across this issue that I haven’t noticed before — in part, because usually text doesn’t seem to be present, and so blurriness is a little less noticable. Both the top and bottom screenshots in the image below […]
Read MoreGulp Minify Javascript
This will put a copy of the minified js file in the same folder in which it was found. It will require the following: useref, gulpif gulp.task(‘jsminify’, function() { return gulp.src([ “!node_modules/**/*.js”, “**/wp-content/themes/**/*.js”, “!**/**.min.js” ], { base: “./” }) .pipe(useref()) .pipe(gulpIf(‘*.js’, uglify())) .pipe(rename({suffix: ‘.min’})) .pipe(gulp.dest(‘./’)); });
Read MoreWordPress Order Posts by a Meta Value
$args = array( ‘post_type’ => ‘sessions’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘session_date’, ‘order’ => ‘ASC’ );
Read MoreWordPress Caption Tag is Appearing in Text
I hit an odd issue where the wordpress caption tag text (actually the shortcode text for the caption) was appearing around the image. I’m gathering the data from a wysiwyg field from ACF. Apparently you need to apply shortcodes to this. Also, my text didn’t have line breaks, so doing something like this solved those issues: […]
Read MoreWordPress Meta Query Mix Relation
Using a mix of ‘And’ and ‘Or’ operators in the meta_query portion of wordpress get posts query. Specifically with this one, I was looking for an event that had a tag specified by the $show variable, and where the date to see if it was current was either the start or end date of the […]
Read MoreWordPress Set Image Upload Size
There are four sizes of images that get created in wordpress when an admin user uploads an image to the media section. You can add more though. To do so, just add the following to the functions.php file: add_image_size(‘custom_size_name’,600,600); In the above, the first number represents the maximum width, and the second is the maximum […]
Read MoreAccessibility Checking
Resources for checking out your site’s accessibility. Lighthouse also provides some checking, but I have a feeling these are a little more robust: https://www.ssa.gov/accessibility/andi/help/install.html https://wave.webaim.org/
Read MoreDifferent Image Files Based on Browser Width
.ipad,.mobile{display:none;} @media(max-width: 768px){ .desktop,.mobile{ display:none; } .ipad{ display:block; } } @media(max-width: 500px){ .desktop,.ipad{ display:none; } .mobile{ display:block; } } <img src=”image-file-desktop” class=”desktop”> <img src=”image-file-ipad” class=”ipad”> <img src=”image-file-mobile” class=”mobile”>
Read More