Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
i created a custom post type but i only get default support features like thumbnails, exerpt etc but what i want is to add all extra features of ceris theme in posts into my custom post type can you help me out?
$args = array(
'label' => __( 'directory', 'Ceris' ),
'description' => __( 'directory all posts', 'Ceris' ),
'labels' => $labels,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt','thumbnail', 'comments', 'revisions', 'custom-fields','post-formats','page-attributes','bk_review_score' ),
// You can associate this CPT with a taxonomy or custom taxonomy.
'taxonomies' => array( 'posts' ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'show_in_rest' => true,
);
check my support array like i'm trying to add bk_review_system into my cpt
yes you can do it
try the following code, BK come with a filter to add widget and there configuration
function bk_child_register_meta_boxes($meta_boxes) {
$meta_boxes[] = array(
'id' => 'bk_review',
'title' => esc_html__( 'BK Review System', 'ceris' ),
'pages' => array( 'directory' ),
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'type' => 'heading',
'name' => esc_html__('Author Review', 'ceris'),
'desc' => esc_html__('This section allow you to give your review, pros, cons', 'ceris'),
),
// Enable Review
array(
'name' => esc_html__( 'Review Box', 'ceris' ),
'id' => 'bk_review_checkbox',
'type' => 'checkbox',
'desc' => esc_html__( 'Enable Review On This Post', 'ceris' ),
'std' => 0,
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
array(
'id' => 'bk_review_box_position',
'name' => esc_html__( 'Review Box Position', 'ceris' ),
'type' => 'select',
'options' => array(
'default' => esc_html__( 'Default -- Under the post content', 'ceris' ),
'top' => esc_html__( 'On top of the post content ', 'ceris' ),
),
// Select multiple values, optional. Default is false.
'multiple' => false,
'std' => 'default',
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
array(
'name' => 'Product Image',
'id' => 'bk_review_product_img',
'type' => 'single_image',
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'name' => esc_html__( 'Product name', 'ceris' ),
'id' => 'bk_review_box_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'name' => esc_html__( 'Description', 'ceris' ),
'id' => 'bk_review_box_sub_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
//Review Score
array(
'name' => esc_html__( 'Review Score', 'ceris' ),
'id' => 'bk_review_score',
'class' => 'ceris-',
'type' => 'slider',
'visible' => array( 'bk_review_checkbox', '=', 1),
'js_options' => array(
'min' => 0,
'max' => 10.05,
'step' => .1,
),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
// Summary
array(
'name' => esc_html__( 'Summary', 'ceris' ),
'id' => 'bk_review_summary',
'type' => 'textarea',
'cols' => 20,
'rows' => 4,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_review_checkbox', '=', 1),
'type' => 'divider',
),
//Pros & Cons
array(
'name' => esc_html__( 'Pros and Cons', 'ceris' ),
'id' => 'bk_pros_cons',
'type' => 'checkbox',
'desc' => esc_html__( 'Enable Pros and Cons On This Post', 'ceris' ),
'std' => 0,
'visible' => array( 'bk_review_checkbox', '=', 1),
),
array(
'visible' => array( 'bk_pros_cons', '=', 1),
'type' => 'divider',
),
array(
'name' => esc_html__( 'Pros Title', 'ceris' ),
'id' => 'bk_review_pros_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'name' => esc_html__( 'Pros (Advantages)', 'ceris' ),
'id' => 'bk_review_pros',
'type' => 'textarea',
'cols' => 20,
'clone' => true,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'visible' => array( 'bk_pros_cons', '=', 1),
'type' => 'divider',
),
array(
'name' => esc_html__( 'Cons Title', 'ceris' ),
'id' => 'bk_review_cons_title',
'type' => 'textarea',
'cols' => 20,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'name' => esc_html__( 'Cons (Disadvantages)', 'ceris' ),
'id' => 'bk_review_cons',
'type' => 'textarea',
'cols' => 20,
'clone' => true,
'rows' => 2,
'visible' => array( 'bk_pros_cons', '=', 1),
),
array(
'type' => 'divider',
),
array(
'type' => 'heading',
'name' => esc_html__('Performance and User Review', 'ceris'),
'desc' => esc_html__('This section allow you to have some criterias and allow your reader to share their review', 'ceris'),
),
array(
'name' => esc_html__( 'Performance and User Review Check Box', 'ceris' ),
'id' => 'bk_performance_review_checkbox',
'type' => 'checkbox',
'desc' => esc_html__( 'Enable This Review', 'ceris' ),
'std' => 0,
),
array(
'visible' => array( 'bk_performance_review_checkbox', '=', 1),
'type' => 'divider',
),
array(
'id' => 'bk_performance_review_score_criteria_group',
// Group field
'type' => 'group',
// Clone whole group?
'clone' => true,
'visible' => array( 'bk_performance_review_checkbox', '=', 1),
// Sub-fields
'fields' => array(
array(
'name' => esc_html__( 'Criteria Title', 'ceris' ),
'id' => 'review_criteria_title',
'type' => 'text',
),
array(
'name' => esc_html__( 'Criteria Score', 'ceris' ),
'id' => 'review_criteria_score',
'class' => 'ceris-',
'type' => 'slider',
'js_options' => array(
'min' => 0,
'max' => 10.05,
'step' => .1,
),
),
),
),
array(
'type' => 'divider',
),
array(
'name' => esc_html__( 'Reader Review Form', 'ceris' ),
'id' => 'bk_reader_review_checkbox',
'visible' => array( 'bk_performance_review_checkbox', '=', 1),
'type' => 'checkbox',
'desc' => esc_html__( 'Enable Reader Review', 'ceris' ),
'std' => 0,
),
)
);
return $meta_boxes;
}
add_filter( 'rwmb_meta_boxes', 'bk_child_register_meta_boxes', 999,1 );
I am using wordpress and 2 plugins called unyson and brizy.
Basically unyson provides me a shortcode I want to call trough the front page builder brizy on my homepage.
I want to call the portfolio shortcode with [portfolio]
This works.
Live website: https://xprs.ch/
Under "Our Work Portfolio"
Now I want to add options:
[portfolio page_link="On" categories="website"]
As long as I just define page_link it works.
But as soon as I try to define the categories I get the following error:
Warning: in_array() expects parameter 2 to be array, string given in /home/httpd/vhosts/xprs.ch/httpdocs/wp-content/themes/jevelin/framework-customizations/extensions/shortcodes/shortcodes/portfolio/views/view.php on line 100
I also get above error if just defining categories so I need to define this different but how?
The code from the shortcode:
NOTE: I cannot change this code.
I need to pass the parameter "website" correctly in the front end.
$options = array(
'id' => array( 'type' => 'unique' ),
'general' => array(
'title' => esc_html__( 'General', 'jevelin' ),
'type' => 'tab',
'options' => array(
'style' => array(
'type' => 'radio',
'label' => esc_html__('Style', 'jevelin'),
'desc' => esc_html__('Choose main style', 'jevelin'),
'choices' => array(
'default' => esc_html__('Standard', 'jevelin'),
'default-shadow' => esc_html__('Standard with Shadow', 'jevelin'),
'default2' => esc_html__('Trendy', 'jevelin'),
'masonry' => esc_html__('Gallery', 'jevelin'),
'masonry2' => esc_html__('Marginless Gallery', 'jevelin'),
'minimalistic' => esc_html__('Minimalistic', 'jevelin'),
),
'value' => 'default',
),
'categories' => array(
'type' => 'multi-select',
'label' => esc_html__('Categories', 'jevelin'),
'desc' => esc_html__('Select categories', 'jevelin'),
'population' => 'taxonomy',
'source' => 'fw-portfolio-category',
'prepopulate' => 200,
'limit' => 100,
),
'page_link' => array(
'type' => 'switch',
'label' => esc_html__( 'Page Link', 'jevelin' ),
'desc' => esc_html__( 'Enable or disable portfolio page link', 'jevelin' ),
'value' => true,
'left-choice' => array(
'value' => false,
'label' => esc_html__('Off', 'jevelin'),
),
'right-choice' => array(
'value' => true,
'label' => esc_html__('On', 'jevelin'),
),
),
),
),
);
How do I need to call categories?
Here:
$cats = array();
foreach( get_the_category() as $cat ) {
$cats[] = $cat->cat_ID;
}
$args = array(
'post_status' => 'publish',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $cats,
'include_children' => false
)
)
);
print_r( WP_Query( $args ) as $post );
http://codex.wordpress.org/Class_Reference/WP_Query
I'm using a wordpress real estate plugin for my project which is wpcasa, I already do some modification, But this thing takes my time to figure out.
I think they use array to get set values/labels on search form.
Anyone can Help me to how to add default value into a search form?
Here's the code below
$defaults = array(
'keyword' => array(
'label' => __( 'Keyword or Listing ID', 'wpcasa' ) . '…',
'type' => 'text',
'class' => 'width-3-4',
'priority' => 10
),
'submit' => array(
'label' => __( 'Search', 'wpcasa' ),
'type' => 'submit',
'class' => 'width-1-4',
'priority' => 20
),
'offer' => array(
'label' => __( 'Offer', 'wpcasa' ),
'key' => '_price_offer',
'data' => wpsight_offers(),
'type' => 'select',
'data_compare' => '=',
'class' => 'width-1-5',
'priority' => 30
),
'location' => array(
'data' => array(
// wp_dropdown_categories() options
'taxonomy' => 'location',
'show_option_none' => __( 'Location', 'wpcasa' ),
'option_none_value' => '',
'hierarchical' => 1,
'orderby' => 'ID',
'order' => 'ASC'
),
'type' => 'taxonomy_select',
'class' => 'width-1-5',
'priority' => 40
),
'listing-type' => array(
'data' => array(
// wp_dropdown_categories() options
'taxonomy' => 'listing-type',
'show_option_none' => __( 'Type', 'wpcasa' ),
'option_none_value' => '',
'hierarchical' => 1,
'orderby' => 'ID',
'order' => 'ASC'
),
'type' => 'taxonomy_select',
'class' => 'width-1-5',
'priority' => 50
),
$details['details_1']['id'] => array(
'label' => $details['details_1']['label'],
'key' => '_details_1',
'data' => $details['details_1']['data'],
'type' => 'select',
'data_compare' => '>=',
'class' => 'width-1-5',
'priority' => 60
),
$details['details_2']['id'] => array(
'label' => $details['details_2']['label'],
'key' => '_details_2',
'data' => $details['details_2']['data'],
'type' => 'select',
'data_compare' => '>=',
'class' => 'width-1-5',
'priority' => 70
)
);
`
Example on keyword I will set a value HOME Instead showing its label.
Thank you!
I got it now I should add 'default' => 'Myvalue',
example
'keyword' => array(
'label' => __( 'Keyword or Listing ID', 'wpcasa' ) . '…',
'type' => 'text',
'class' => 'width-3-4',
'default' => 'HELLO',
'priority' => 10
),
Thanks for the help/advice!
I've got some custom fields as meta data for a new post type - Properties (for an estate agents), so want to search by number of bedrooms, min/max value and location. I have a form with multiple drop-downs for each of these fields:
location, min_value, max_value, bedrooms
Also, I have meta boxes on the posts themselves, so one for price, bedrooms, location, and a taxonomy type of property_type - rent, sale, and commerical.
I've found this piece of code online but not sure how to manipulate it so it takes whatever value the form takes?
$args = array(
'post_type' => 'product',
'meta_query' => array(
array(
'key' => 'location',
'value' => '[LOCATION HERE]',
'compare' => 'NOT LIKE'
),
array(
'key' => 'price',
'value' => '[PRICE HERE FROM FORM]',
'type' => 'numeric',
'compare' => 'BETWEEN'
)
)
);
$query = new WP_Query( $args );
Also, I understand the search query goes on function.php but do I call it from where the form is, or where the results are outputted? ie. my homepage or my searchpage?
Hope someone can help
use this code
$args = array(
'post_type' => 'Properties',
'meta_query' => array(
array(
'key' => 'location',
'value' => '[LOCATION HERE]',
'compare' => 'LIKE'
),
array(
'key' => 'min_value',
'value' => '[min value here]',
'type' => 'numeric',
'compare' => 'BETWEEN'
)
array(
'key' => 'max_value',
'value' => '[max value here]',
'type' => 'numeric',
'compare' => 'BETWEEN'
)
array(
'key' => 'bedrooms',
'value' => '[bedroom here]',
'compare' => 'LIKE'
),
)
);
$query = new WP_Query( $args );
and You have to call this in your searchpage....
Thanks for help Yogesh, I modified your answer to get this which seems to work:
<?php $args = array(
'post_type' => 'Property',
'property_type'=>$_GET['type'],
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_property_info_location',
'value' => Cuztom::uglify($_GET['location']),
),
array(
'key' => '_property_info_bedrooms',
'value' => $_GET['bedrooms'],
),
array(
'key' => '_property_info_price',
'value' => $_GET['max_value'],
'compare' => '<=',
'type' => 'numeric',
),
array(
'key' => '_property_info_price',
'value' => $_GET['min_value'],
'compare' => '>=',
'type' => 'numeric',
),
),
);
$the_query = new WP_Query( $args );
?>