This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$term = wp_create_term($term_name, 'taxonomy'); // will return existing term if exists already | |
wp_set_post_terms($post_id, $term_name, 'taxonomy'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function upload_image($file_name, $parent_post_id) { | |
$file = './img/'.$file_name; | |
$filename = basename($file); | |
$upload_file = wp_upload_bits($filename, null, file_get_contents($file)); | |
if (!$upload_file['error']) { | |
$wp_filetype = wp_check_filetype($filename, null ); | |
$attachment = array( | |
'post_mime_type' => $wp_filetype['type'], | |
'post_parent' => $parent_post_id, | |
'post_title' => preg_replace('/\.[^.]+$/', '', $filename), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple ACF Field insertion based on explanation here: | |
// https://support.advancedcustomfields.com/forums/topic/acf-repeater-filed-in-add_post_meta/ | |
// and the awesome Get Field Key https://gist.github.com/mcguffin/81509c36a4a28d9c682e | |
function insert_acf_post_meta($key, $value_to_insert, $id) { | |
$field_name = $key; | |
$field_name__ = "_".$field_name; | |
$field_key = acf_get_field_key( $field_name, $id ); | |
add_post_meta($id, $field_name, $value_to_insert, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{!! $html !!} - Outputs HTML | |
{{ $var }} - Echo content | |
{{ $var or 'default' }} - Echo content with a default value | |
{{{ $var }}} - Echo escaped content | |
{{-- Comment --}} - A Blade comment | |
@extends('layout') - Extends a template with a layout | |
@if(condition) - Starts an if block | |
@else - Starts an else block | |
@elseif(condition) - Start a elseif block | |
@endif - Ends a if block |