fixed wp query by tag_id

This commit is contained in:
jorge 2022-07-25 10:10:45 +02:00
parent 747156da7a
commit 1d91f21361
1 changed files with 16 additions and 16 deletions

View File

@ -188,7 +188,7 @@ class PFTWidget extends WP_Widget {
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'post_tag' ) ); ?>"><?php esc_html_e( 'Select Tag:', 'PFT' ); ?></label>
<?php
$cat_args = array(
$tag_args = array(
'orderby' => 'name',
'hide_empty' => 1,
'class' => 'widefat',
@ -196,9 +196,9 @@ class PFTWidget extends WP_Widget {
'name' => $this->get_field_name( 'post_tag' ),
'id' => $this->get_field_id( 'post_tag' ),
'selected' => absint( $instance['post_tag'] ),
'show_option_all' => esc_html__( 'All Categories','PFT' ),
'show_option_all' => esc_html__( 'All Tags','PFT' ),
);
wp_dropdown_categories( $cat_args );
wp_dropdown_categories( $tag_args );
?>
</p>
@ -430,10 +430,10 @@ function pft_init_shortcode( $atts ) {
extract( shortcode_atts(
array(
'layout' => 'layout-one',
'cat' => '',
'tag_id' => '',
'order_by' => 'date',
'order' => 'DESC',
'post_number' => 5,
'post_number' => 4,
'exclude' => '',
'length' => 10,
'readmore' => esc_html__('Read More', 'PFT'),
@ -446,7 +446,7 @@ function pft_init_shortcode( $atts ) {
ob_start();
pft_call_shortcode_details( $layout, $cat, $order_by, $order, $post_number, $exclude, $length, $readmore, $show_date, $show_image, $image_size );
pft_call_shortcode_details( $layout, $tag_id, $order_by, $order, $post_number, $exclude, $length, $readmore, $show_date, $show_image, $image_size );
return ob_get_clean();
}
@ -481,7 +481,7 @@ function pft_call_shortcode_details( $layout, $post_tag, $order_by, $order, $pos
if ( absint( $post_tag ) > 0 ) {
$p_args['cat'] = absint( $post_tag );
$p_args['tag_id'] = absint( $post_tag );
}
@ -614,28 +614,28 @@ if ( !function_exists( 'pft_tinymce_custom_vars' ) ) {
function pft_tinymce_custom_vars() {
$cat_args = array(
$tag_args = array(
'orderby' => 'name',
'hide_empty' => 1,
'taxonomy' => 'post_tag',
);
$cat_count = 1;
$tag_count = 1;
$cat_params[0] = array(
$tag_params[0] = array(
'text' => esc_html__( 'Select Tag', 'PFT' ),
'value' => 0
);
$post_tags = get_categories( $cat_args );
$post_tags = get_categories( $tag_args );
foreach ( $post_tags as $cat ) {
foreach ( $post_tags as $tag ) {
$cat_params[$cat_count]['text'] = $cat->name;
$tag_params[$tag_count]['text'] = $tag->name;
$cat_params[$cat_count]['value'] = $cat->term_id;
$tag_params[$tag_count]['value'] = $tag->term_id;
$cat_count++;
$tag_count++;
}
//For image sizes
@ -701,7 +701,7 @@ if ( !function_exists( 'pft_tinymce_custom_vars' ) ) {
array(
'button_name' => esc_html__(' PFT ', 'PFT'),
'button_title' => esc_html__('Posts From Tag', 'PFT'),
'post_tag_list' => $cat_params,
'post_tag_list' => $tag_params,
'image_sizes' => $image_size,
)
);