LoginSignup
3
7

More than 3 years have passed since last update.

wordpress久しぶりだと毎回ググるよね備忘録

Last updated at Posted at 2018-11-18

もう100回はググってんじゃないの?

どうも、wordpress専門のエンジニアではないので着手するたびほぼ初心者の気持ちに戻っていて流石にググる時間無駄すぎわロタの人です。(長い
今回は毎回毎回毎回毎回ググらざるおえない系を乱雑に書いていきます。
もう脈略もクソもないのですが、「あーwpお久しぶりー」って言う人はここみるとなんとなく記憶が蘇るんじゃないかなと思います。

style.cssの読み込み方

functions.phpからやろうな

<?php 

function add files() {
  wp_deregister_script('jquery');
  // wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js', "", "20160608", false );
  wp_enqueue_style( 'main', get_stylesheet_uri() );
  wp_enqueue_style( 'medium', get_template_directory_uri() . '/css/medium.css', '', '' );
  wp_enqueue_style( 'small', get_template_directory_uri() . '/css/small.css', '', '' );
  wp_enqueue_style( 'sp', get_template_directory_uri() . '/css/sp.css', '', '' );
}

// add_action('wp_enqueue_scripts', 'add_files');
add_action('', 'add_files');

?>

header.php内の直前にこの記述も忘れないようにしような

<?php wp_head()?>

homeURL(ページ自体のURL)

<?php $url = home_url(); ?>

imageの読み方(テーマディレクトリーまでのURL)

//pugの場合
img(src!= "<?php echo get_template_directory_uri(); ?>/images/title.svg")

//htmlの場合
<img src="<?php echo get_template_directory_uri(); ?>/images/title.svg">

toppageに固定ページのテキストを反映

//下ごしらえ
<?php
$post_data = get_page_by_path('ここに固定ページのスラッグ'); 
$post = get_post($post_data);
$post_contents = $post -> post_content;
?>

//出力
<?php echo strip_tags($post_contents); ?>

サムネイルを出す

<?php the_post_thumbnail(); ?>
3
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
7