Skip to content

Instantly share code, notes, and snippets.

View kaoru-fukusato's full-sized avatar

かおちんサポート・メモ帳 kaoru-fukusato

View GitHub Profile
@kaoru-fukusato
kaoru-fukusato / gist:86567b25596e0b8c71f5875bbe5d90cc
Created August 11, 2024 20:02
Unityでマウス操作の制御、目線の固定
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class look : MonoBehaviour
{
float xRot;
float yRot;
// Start is called before the first frame update
void Start()
@kaoru-fukusato
kaoru-fukusato / gist:ade1f24a5ab61b3adaa3b56b1302ed69
Created August 11, 2024 19:31
スクリプト AudioPlayer コンポーネントの設定
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class audioclip : MonoBehaviour
{
public AudioClip audioClip1;
public AudioClip audioClip2;
public AudioClip audioClip3;
public AudioClip audioClip4;
@kaoru-fukusato
kaoru-fukusato / Facebookページ
Created July 25, 2021 22:21
Facebookページとアプリを紐付け
https://www.facebook.com/dialog/pagetab?app_id=(App IDの入力)&display=popup&next=(Secure Page Tab URLの入力)
を直打ちでアドレスバーに入力し、アクセスします。
@kaoru-fukusato
kaoru-fukusato / 動画背景 全画面表示 スマホ対応
Last active April 19, 2020 22:14
動画背景 全画面表示 スマホ対応
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<meta charset="UTF-8">
<title>あれこれ</title>
<meta name="keywords" content="あれこれ" />
<meta name="description" content="あれこれ" />
<script src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
<script src="main.js"></script>
@kaoru-fukusato
kaoru-fukusato / Advanced Random Posts動作しない時の対処法
Last active March 16, 2020 04:08
Advanced Random Posts Widgetが動作しない時の対処法
function shortcode_random_posts( $param ) {
return random_posts($param[0] , $param[1]); //0:カテゴリーID(0はカテゴリ指定なし) 1:表示記事数
}
add_shortcode('random_posts','shortcode_random_posts');
動作方法(ショートコードの書き方)
表示したい箇所(本記事のように投稿内)にショートコードを下記のように記載します。
[random_posts カテゴリID 個数]
このように記載すると指定カテゴリIDの記事を指定個数分、リンク付きで、アイキャッチ画像とタイトルを表示します。
※カテゴリID=0を指定するとすべての投稿を対象とします。
プラグイン実装(ソースをほぼ加工なしで表示しています)
・class指定やCSS定義などは省略しています。
ショートコード実装
@kaoru-fukusato
kaoru-fukusato / index.phpでランダム表示
Created March 15, 2020 13:47
index.phpでランダム表示
//私の現在の作業コードの場合
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
/////////////////////////
//テーマのfunctions.phpファイルに次のコードを配置します。
function one_random_post_on_home_page( $query )
{
if ( ! ( $query->is_home() && $query->is_main_query() ) )
@kaoru-fukusato
kaoru-fukusato / ランダム表示
Created March 15, 2020 10:56
taxonomy.phpで一覧をランダム表示
<?php query_posts($query_string . "&orderby=rand"); ?>
@kaoru-fukusato
kaoru-fukusato / functions.php
Created March 15, 2020 10:00
記事ランダムをショートコードとして使う場合
[random_posts limit=5]
<?php
function random_posts($attrs = array()){
ob_start();
$limit = !empty($attrs['limit']) ? $attrs['limit'] : 0;
?>
<?php
$args = array(
'post_type' => 'post',
<?php query_posts(array('orderby' => 'rand', 'showposts' => 5));
if (have_posts()) :
while (have_posts()) : the_post(); ?>
/* 繰り返し表示させる部分 */
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content(); ?>
<?php endwhile; endif; ?>