i'm a music producer and new to coding. I'm working on my website and i have created a custom taxonomy called "genre" which is linked to a custom post type called "my-music". below is the code i used for the options when adding genres to display on a page. please see the attached image for reference. athis image (https://drive.google.com/file/d/1liovGGOnjgx-IxjMklk1ZVNyyCaBpqXF/view?usp=sharing).
<?php if (!defined('FW')) die('Forbidden');
`$options = array(
'genre_heading' => array(
'label' => __('Title', 'miraculous'),
'type' => 'text'
),
'number_limits' => array(
'label' => __('Number of genre', 'miraculous'),
'type' => 'text'
),
);
The above code and attached image then display the created values under the genre taxonomy. please this image for reference. ( https://drive.google.com/file/d/191ArcB0y1sh9vuKynkknHrhP7GOCJ7Sv/view?usp=sharing ). by Default it display the genres by alphabetical order, i would like to add an option to the above codes called display order which should include 3 select options 1. Most Played 2.Alphabetical Order 3.Top Rated.
The "my-music' custom post type already has a function called (miraculous_song_view_counter) which counts how many times a song has been played. this is the code i used to create it ( https://drive.google.com/file/d/1kbcHW476CvFH5xIsjsXT0PIDtUIgLOVE/view?usp=sharing ). and i'm using Unyson feedback extension for rating posts. Is there a way to use the data collected from this rating submissions and music count function to create those display order options?
Related
My goal is to get a signed-in user to select a color( via front end form and saved in ACF user meta field group) that will be applied to another user meta field inside a repeater. The field must be the same for each row inside the repeater ( for front-end design reasons ). I am using ACF pro, and a plugin called ACF Front end admin (let's call it FEA from now on) for the front-end form. I'm pretty new to PHP and have referenced ACF & FEA's s documentation, which can be found below, spin up a custom function. I am currently running this through the code snippets plugin if this helps. I've run an error log and nothing related to this shows. Tried running this through wp-config and it crashes my site.
Front end admin documentation
ACF documentation - update sub field
ACF documentation - getting values from a user
Edit, Additional information:
ACF Field composition of 'button color' (color of the buttons that user wants displayed in front end, and saved as user meta):
acf_add_local_field_group(array(
'key' => 'group_60000aaa00000',
'title' => 'Color Selector',
'fields' => array(
array(
'key' => 'field_60000aaa00000',
'label' => 'Button color',
'name' => 'button_color',
'type' => 'color_picker',
Button color in repeater field that needs to updated based on the above mentioned 'button_color' meta value:
acf_add_local_field_group(array(
'key' => 'group_70000bbb00000',
'title' => 'front end user profile',
'fields' => array(
array(
'key' => 'field_70000bbb00000',
'label' => 'Quick Link selector',
'name' => 'quick_link_selector',
'type' => 'repeater',
),
array(
'key' => 'field_70000ccc00000',
'label' => 'repeater button color',
'name' => 'repeater_button_color',
'type' => 'text',
The title of the forum is: "QL color selector form" (created through the FEA plugin) and has a short code of [frontend_admin form="3030"] if this helps.
I'm running the following code with no luck and would really appreciate any help!
/// Hooks into any(?) form and does something
add_action('acf_frontend/save_user', 'retrieve_colors_2_update', 10, 2);
function retrieve_colors_2_update( $form, $user_id ) {
$user = get_user_by('ID',$user_id);
//get important fields
$btn_color = get_field('button_color', 'user_' .$user_id);
//// update a repeater loop (ACF)
if( have_rows('quick_link_selector', 'user_'.$user_id) ) {
$i = 0;
while( have_rows('quick_link_selector') ) {
the_row();
$i++;
update_sub_field('repeater_button_color', $btn_color );
}
}
}
I'm trying to create a dropdown list with the list of a certain post type.
I saw that I could use the wp_dropdown_pages function to do that.
I added this code inside my td but when the page displays the code is not interpreted. The are only few examples to look at.
<td><?php wp_dropdown_pages(array('id'=>'marque0','post_type' => 'Brands')); ?></td>
additionally I need to filter a second dropdown list which contains only child post of the parent selected in the first dropdown. To do that I need the id of the parent post. How can I get this from the element selected in the first dropdown list ?
Thanks a lot.
Update :
I found a way to go around the usage of PHP inside the wordpress page, I created shortcodes to call the wp_dropdown_pages, then I use the shortcodes inside my page.
Surprisingly enough (!), just specify in your custom post type's settings 'hierarchical' => true, not the hierarchical argument in wp_dropdown_pages() function.
register_post_type( 'brands', array(
'labels' => array(
..........
),
.........
'hierarchical' => true,
.........
));
Then it should work:
wp_dropdown_pages(array(
'id' => 'marque0',
..........
'post_type' => 'brands'
));
I am using the Posts to Post plugin for Wordpress (version: 1.6.3) to link my posts with a custom post type I created. This custom post type consists of 'authors' that can be linked to a post. Yesterday it was functioning as it should but as for today, the overview is generating a list of 'posts' instead of a list of 'authors'.
I am using the following function to generate a list of authors.
function my_connection_types() {
p2p_register_connection_type( array(
'name' => 'posts_to_auteurs',
'from' => 'post',
'to' => 'auteur'
) );
}
add_action( 'p2p_init', 'my_connection_types' );
Does anyone know what's wrong? I'm dying for help...
I'm using the WPAlchemy class to create a metabox. I want to place this metabox in a number of post editors in the backend.
Currently it's working just fine with the following code:
$video_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_videoMeta',
'title' => 'Videos',
'types' => array('characters','homepage'),
'template' => THEMEASSETS . '/functions/video_meta.php'
));
What I want to do though is additionally place the metabox on the post editor for post ID #22. Supposedly the following code should work:
$video_metabox = new WPAlchemy_MetaBox(array
(
'id' => '_videoMeta',
'title' => 'Videos',
'types' => array('characters','homepage'),
'template' => THEMEASSETS . '/functions/video_meta.php',
'include_post_id' => 22
));
But it doesn't work unless I add in 'page' into the array of post types, which adds the metabox to all pages (not just post ID 22).
Is there a way to use poth the types and the include post ID arguments?
I had the same issue. Acutally, I had set a metabox to two custom post types and wanted it to be displayed on a specific page.
$video_metabox = new WPAlchemy_MetaBox(array(
'id' => '_videoMeta',
'title' => 'Videos',
'types' => array('characters','homepage', 'page'),
'template' => THEMEASSETS . '/functions/video_meta.php',
'include_post_id' => 22
));
Just add the bult in 'page' post type and everything should work fine. It did for me.
Alright, so I'm working on my own script that reads specific xml files, and imports products. Now, each of these products may have a set of attributes, (i.e. color for example).
So, what I'm doing is importing each custom attribute, and generating a specific string, "Yellow, black finish wood" for example, and that would be a radio button you could select from when you go to order the product. Now, when I come to a product that has the same "parentid" but a different unique id, I need to generate a new row for the custom option radio button, so if there is another product where the color is red, I would have the following to select from:
Red, black finish wood
Yellow, black finish wood
This is working great for the first product with the same parent id, in other words, if I'm creating a brand new product, and not just adding custom options to the same product.
My question is, how do I generate a new custom option value, for the specific option? In other words, how do I add a new row to a certain option that is already created?
Here is basically what I'm doing to generate the first option on a new product.
$options = array();
$options[$ParentID] = array(
'title' => 'Option Title',
'type' => 'radio',
'is_require' => 1,
'values' => array()
);
$options[$ParentID]['values'][] = array(
'title' => 'Option Value Title',
'price' => 0.00,
'price_type' => 'fixed',
'sku' => $UniqueID,
);
foreach($options as $ParentID => $option) {
$id = Mage::getModel('catalog/product')->getIdBySku($ParentID);
$product = Mage::getModel('catalog/product')->load($id);
if(!$product->getOptionsReadonly()) {
$product->setProductOptions(array($option));
$product->setCanSaveCustomOptions(true);
$product->save();
}
}
this works out great, because magento generates an sku when they order a certain product in the format of $ParentID_$UniqueID, and then I can send the $UniqueID off to the vendor for the order.
So again, I'm open to suggestions as to how to add a Option Value to an already created Custom Option
load all options in and create array map with unique and already existing options to get their id -s in place