質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Q&A

解決済

2回答

585閲覧

プラグインのファイルに一部追加したい

rokiroki1005

総合スコア10

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

0グッド

0クリップ

投稿2022/03/27 04:52

使用プラグインはAll-in-One Video Galleryで、プラグインからショートコードを作成できるのですが現在の並び順がorder=ascになっております。

そのためorder=descを該当するphpファイルに追加しました。
反映はされたのですが、プラグインをアップデートをしたら消えてしまうので消えないようにするために色々と調べたら以下のURLから独自のテンプレートを作成できることを知り、フォルダやファイルを作成したものの反映されなく困っております。

https://plugins360.com/all-in-one-video-gallery/child-themes-and-templates/

独自テンプレート

PHP

1<?php 2/* 3 * Plugin Name: AIOVG – Custom Templates 4 * Plugin URI: https://plugins360.com 5 * Description: This plugin replaces default All-in-One Video Gallery plugin public/templates/search-form-template-horizontal.php file with search-form-template-horizontal.php file inside this plugin directory. 6 * Author: Team Plugins360 7 */ 8 9// Exit if accessed directly 10if ( ! defined( 'WPINC' ) ) { 11 die; 12} 13 14function aiovg_custom_videos_template( $tpl ) { 15 // $tpl is an absolute path to a file, for example 16 // ../public_html/wp/wp-content/plugins/all-in-one-video-gallery/public/templates/search-form-template-horizontal.php 17 18 $basename = basename( $tpl ); 19 // search-form-template-horizontal.php 20 21 if ( 'search-form-template-horizontal' == $basename ) { 22 // return path to search-form-template-horizontal.php file in aiovg-custom-templates directory 23 return dirname( __FILE__ ) . '/search-form-template-horizontal.php'; 24 } else { 25 return $tpl; 26 } 27} 28 29add_filter( 'aiovg_load_template', 'aiovg_custom_videos_template' );

該当するPHP

PHP

1<?php 2 3/** 4 * Search Form: Horizontal Layout. 5 * 6 * @link https://plugins360.com 7 * @since 1.0.0 8 * 9 * @package All_In_One_Video_Gallery 10 */ 11?> 12 13<div class="aiovg aiovg-search-form aiovg-search-form-template-horizontal"> 14 <form method="get" action="<?php echo esc_url( aiovg_get_search_page_url() ); ?>"> 15 <?php if ( ! get_option('permalink_structure') ) : ?> 16 <input type="hidden" name="page_id" value="<?php echo esc_attr( $attributes['search_page_id'] ); ?>" /> 17 <?php endif; ?> 18 19 <?php if ( $attributes['has_keyword'] ) : ?> 20 <div class="aiovg-form-group aiovg-field-keyword"> 21 <input type="text" name="vi" class="aiovg-form-control" placeholder="<?php esc_attr_e( 'Enter your Keyword', 'all-in-one-video-gallery' ); ?>" value="<?php echo isset( $_GET['vi'] ) ? esc_attr( $_GET['vi'] ) : ''; ?>" /> 22 </div> 23 <?php endif; ?> 24 25 <?php if ( $attributes['has_category'] ) : ?> 26 <div class="aiovg-form-group aiovg-field-category"> 27 <?php 28 $categories_args = array( 29 'show_option_none' => '-- ' . esc_html__( 'Select a Category', 'all-in-one-video-gallery' ) . ' --', 30 'option_none_value' => '', 31 'taxonomy' => 'aiovg_categories', 32 'name' => 'ca', 33 'class' => 'aiovg-form-control', 34 'orderby' => 'name', 35 'order' => 'desc',//こちらを追加 36 'selected' => isset( $_GET['ca'] ) ? (int) $_GET['ca'] : '', 37 'hierarchical' => true, 38 'depth' => 10, 39 'show_count' => false, 40 'hide_empty' => false, 41 ); 42 43 $categories_args = apply_filters( 'aiovg_search_form_categories_args', $categories_args ); 44 wp_dropdown_categories( $categories_args ); 45 ?> 46 </div> 47 <?php endif; ?> 48 49 <?php if ( $attributes['has_tag'] ) : ?> 50 <div class="aiovg-form-group aiovg-field-tag"> 51 <?php 52 $tags_args = array( 53 'taxonomy' => 'aiovg_tags', 54 'orderby' => 'name', 55 'order' => 'asc', 56 'hide_empty' => false 57 ); 58 $terms = get_terms( $tags_args ); 59 60 $selected_tags = array(); 61 if ( isset( $_GET['ta'] ) ) { 62 $selected_tags = array_map( 'intval', $_GET['ta'] ); 63 $selected_tags = array_filter( $selected_tags ); 64 } 65 66 // Dropdown 67 echo '<select class="aiovg-form-control">'; 68 echo '<option value="">-- ' . esc_html__( 'Select Tags', 'all-in-one-video-gallery' ) . ' --</option>'; 69 70 if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { 71 foreach ( $terms as $term ) { 72 printf( 73 '<option value="%d"%s>%s</option>', 74 $term->term_id, 75 ( in_array( $term->term_id, $selected_tags ) ? ' disabled' : '' ), 76 esc_html( $term->name ) 77 ); 78 } 79 } 80 81 echo '</select>'; 82 ?> 83 </div> 84 <?php endif; ?> 85 86 <div class="aiovg-form-group aiovg-field-submit aiovg-hidden-mobile"> 87 <input type="submit" class="aiovg-button" value="<?php esc_attr_e( 'Search', 'all-in-one-video-gallery' ); ?>" /> 88 </div> 89 90 <?php 91 if ( $attributes['has_tag'] ) { 92 // Tags List 93 echo '<div class="aiovg-tags-list">'; 94 95 if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { 96 foreach ( $terms as $term ) { 97 if ( in_array( $term->term_id, $selected_tags ) ) { 98 $html = '<span class="aiovg-tag-item" data-id="' . (int) $term->term_id . '">'; 99 $html .= '<span class="aiovg-tag-item-name">' . esc_html( $term->name ) . '</span>'; 100 $html .= '<span class="aiovg-tag-item-close">&times;</span>'; 101 $html .= '<input type="hidden" name="ta[]" value="' . (int) $term->term_id . '" />'; 102 $html .= '</span>'; 103 104 echo $html; 105 } 106 } 107 } 108 109 echo '</div>'; 110 } 111 ?> 112 113 <div class="aiovg-form-group aiovg-field-submit aiovg-hidden-desktop"> 114 <input type="submit" class="aiovg-button" value="<?php esc_attr_e( 'Search', 'all-in-one-video-gallery' ); ?>" /> 115 </div> 116 </form> 117</div> 118

色々と調べたのですが解決策が見つからなく、お手数ですがご教授の方宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

functions.php

1 add_filter( 2 'aiovg_search_form_categories_args', 3 function( $categories_args ) { 4 $categories_args['order'] = 'desc'; 5 return $categories_args; 6 } 7);

投稿2022/03/27 10:56

rokiroki1005

総合スコア10

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

テンプレートまで差し替えるのではなく、
↓このフィルターにフックして 'order'を書き換えてみては?

PHP

1$categories_args = apply_filters( 'aiovg_search_form_categories_args', $categories_args );

投稿2022/03/27 05:39

kei344

総合スコア69407

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

rokiroki1005

2022/03/27 06:06

迅速なご回答ありがとうございます。 フックの方法はわかるのですが、書き換え方法がわからなく。。 ご教授頂けますと幸いです。 宜しくお願い致します。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問