How to Display WooCommerce Product Price in WooCommerce Archive

I have created a custom function to display 2 custom fields (ACF) and the price of the product after the item in the WooCommerce Archive/Shop page. My Custom fields are show, but I am unable to get the WooCommerce price. How can I fix my function to show the price? add_action( 'woocommerce_after_shop_loop_item', 'acf_template_loop_product_meta', 20 ); function acf_template_loop_product_meta() { global $product; if ( $brand = get_field('brand', $product->get_id()) ) { echo '<p><strong>'. __("   &nbsp") . '</strong> ' . $brand . '</p>'; } if …
Category: Web

How to create the training set?

I am working on a project related to Machine Learning in wireless communication. Here I have to prepare the training set as that consists of training features and training labels as: $S = [(x_1,y_1),...,(x_M,y_M)] \in (X \times Y)^M$ ------(1) where $m$ ranges from 1 to 10^5, $y_m$ is the training label such that $y_m$ $\in$ {-1,1} and $x_m$ is the training features given as $x_m = [\epsilon(m)_- \epsilon(m)_+] \in \mathcal{R}^2$. Please note that I can obtain the $\epsilon(m)_-$ and $\epsilon(m)_+$ …
Category: Data Science

Hook to use when customer placing order

Currently I am using woocommerce_thankyou action to run a function that creates an order at a third party service. However, sometimes customers don't return to the Thank You page after visiting our Payment Service Provider, resulting in no order being created at the third party. Would it be better to use the woocommerce_order_status_completed action? Any other hooks I could use? Is there a scheme/rundown available somewhere of all the actions that follow eachother? Any other ideas to solve this problem?
Category: Web

ValueError: Expected 2D array, got 1D array instead

I would like to extract the 20 most informative features of a very large set of features $X$ coming from a dataset containing clinical data by using the RFE function from scikit-learn in Python. $X$ is a 68 x 1140 matrix where Each row represents a recorded session. For each subject, there are 4 recorded sessions. Then, there are 17 subjects in the dataset. My idea is to use 70% of the dataset (i.e. 70% x 1140 random features from …
Category: Data Science

Find variables available at a given hook

I'm hoping for a simple way to tell/find/echo what the available arguments are available for use at a given hook. For example — function example_function($something){ //do stuff with $something return $something; } add_action('some_hook','example_function'); In the above case, is there a quick way to tell what $something is (if there is one at all), or if there are multiple $somethings / arguments I have available to use at that point?
Category: Web

How to Dynamically Load Content Into Body of Bootstrap Modal Window?

I found this answer on Stack Overflow, answer this exact question. I've modified it slightly, because I'm using a button and not an anchor: jQuery( ".modal" ).on( "show.bs.modal", function ( e ) { var target = jQuery( e.relatedTarget ).attr( "data-target" ).replace( "#", "" ); var modal_ids = [ "modal-request-estimate", "modal-schedule-appointment", "modal-rate-review" ]; if ( modal_ids.indexOf( target ) == - 1 ) { return false; } jQuery( this ).find( ".modal-body" ).load( location.href + "?modal=" + target ); } ); If then …
Category: Web

statistical significance test between binary label features

I have 667 features and I want to find features that have a significant boundary between a binary class label before I apply a classification model (e.g Naive Bayes/ SVM) to improve classification model learning rate. What I know is, if the features' values between the two classes are overlapping, this will cause poor classification. Hence, I have done a 2 samples t-test to calculate the statistical significance of features between binary class label. from scipy import stats p=[] failure …
Category: Data Science

WORDPRESS Embeded MAP width change

https://www.hammertonbrewery.co.uk/site/tint-nitro-london-dry-stout-4-3/ On the webpage above I need to do the below on my GOOGLE MAP: – Reduce width of MAP – Ensure MAP is in the centre of the page Any help advice on how to do this would be greatly appreciated. Thank you
Category: Web

Post in multiple categories do not include in previous / next post if one category in excluded

I have read the following post which appears to solve my problem but doesn't... excluded_categories parameter in next_post_link() behaving unexpectedly I have posts in say 3 categories but if they are included in category 'update' (which is ID 96) I would like them excluded from the previous / next navigation system. From the above post I have edited the following code (this is all in my functions.php file as the single.php template calls for the navigation from there). <?php previous_post_link( …
Category: Web

Statistically increase mean difference between two data sets?

A dataset will be used to train a binary classification model. For better understanding/visualization, the data set was divided into 2: one set with all the rows that result in prediction value of 1 another set with all the rows that result in prediction value of 0 Comparing both datasets, there are small, but expected differences in many of the features. For example, a lower mean or median. Is there a sound way to statistically enhance the data to make …
Category: Data Science

Next and Previous Page links based on 'Order' attribute

I'm trying to add Next and Previous links to my site Pages (not Posts) to navigate based on the 'Order' information. I copied some code from the Codex (https://codex.wordpress.org/Next_and_Previous_Links) that works fine (displays the pages in the right order - not cronological) except on the first and last pages where I get an error. The error shows "Undefined array key" where the Previous link on the first page should be and the same error (different array entry) where the Next …
Category: Web

Modify php code from plugin

I'd like to modify a plugin's php file that has only a bunch of if/else and echo statements. I can do it by copying the file into the child theme folder and changing the one little thing, but if the theme gets updated, these updates won't get into the copied file, will they? Here is part of the file: <a class="logout with-icon" href="<?php echo wp_logout_url( get_permalinks() ) ?>" data-icon=""><?php _e('Log out', 'franklin') ?></a> <?php elseif ( $crowdfunding_enabled && ! is_user_logged_in() …
Category: Web

Setting up Neural Network for this problem

I have a question regarding neural networks considering I am not an expert in NN. Assume have a 5 by 5 grid that depending on me pushing any square (or combination of squares) some of those squares (not necessarily the squares I have pushed) will light up. My question is: Can we set this problem as a NN problem if I have a set of input and outputs? Assume input layer with 25 neurons where all are zero except the …
Category: Data Science

How can I add a shortcode to query Custom Post Type with ACF in Wordpress?

I am building a website for a client, and I needed to build a game release calendar using Custom Post Type and Advanced Custom Fields. Everything is built out, but the last step. I need to be able to query the CPT automatically whenever a new game is added, and pull it into the WP Bakery Visual Composer front end via shortcode. Below is the code added to the functions.php file, but I'm getting syntax errors because of "<". Can …
Category: Web

Prevent posts with certain post_meta to be edited

So I am looking at adding some custom post_meta to posts and I want those posts to not be editable, which will be some content that I am pulling in. Here is what I have: I have solved the issues when visiting the Post post_type and attempting to edit a post with a specific post_meta using this (This works great in the UI): add_filter('post_row_actions', function($actions, $post) { if (get_post_meta($post->ID, 'global_post', true)) { unset($actions['edit']); unset($actions['inline hide-if-no-js']); } return $actions; }, 10, …
Category: Web

How do I stop a dynamic Gutenberg component from re-rendering on every keystroke?

I'm using some dynamic components inside a custom block; predominantly used for input fields inside the <InspectorControls> component. Below are the relevant portions of the custom block. import summaryTypes from './components' // Dynamically set the component function SummaryTitle(props) { const ThisComponent = summaryTypes.find((c) => c.value === summaryType).components.title return <ThisComponent {...props}/> } // Slot fill provider const TitleSlotFill = () => { const TitleSlot = () => <Slot name="TitleSlot"/> TitleSlot.Content = () => ( <Fill name="TitleSlot"> <SummaryTitle content={title} onUpdate={(title) => setAttributes({title})} …
Category: Web

How to install WordPress on root domain and Php script on subdomain?

I have built a website using WordPress. I installed WordPress on root domain i.e www.example.com . Now I want to install a Php Script based website on subdomain and subdirectories i.e subdomain.example.com and www.example.com/subdirectory. I know it is possible to do this but I need the working process to make it possible. If anyone know this then please guide me.
Category: Web

Fully endogenous models for predicting multivariate time series

I have a formal social science background but I am new to data science. My interest is in building predictive models for applications in the social sciences, mostly (but not only) in economics. I am interested in the following kind of setups: I have data that describe the evolution of a number of variables $j \in J$ for a number of "individuals" $i\in N$ across time periods $t \in \{1\dots, T\}$. For example, "individuals" $i\in N$ could be countries, with …
Category: Data Science

Optimal clusters for K-means not clear - any ideas?

I have a toy dataset of 10,000 strings of people's names, addresses and birthdays. As a quirk of the data collection process it is highly likely there are duplicate people caused by typos and I am trying to cluster them using K-means. I know there are easier ways of doing this, but the reason I am doing it like this is out of curiosity. In order to vectorize each person I am concatenating the strings as follows: [name][address][birthday] and then …
Category: Data Science

How to duplicate a page template but make minor changes to the header?

I will apologize in advance, I am very new to this. I have been teaching myself php as a hobby, but now I need it for work! I don't work as a web designer, but to try and save some money, I need to be able to make minor changes to our website. I can handle most things... But this one issue is throwing me for a loop. The page was designed by a "marketing firm" and the code is …
Category: Web

Clustering sets based on common elements

I am looking for a clustering algorithm for the purposes of combining routing information. Suppose we have the following sets: A={1,2,3,4,5} B={2,3,4,6} C={3,4,7,8} D={8,9,10,11} If we want 3 groups, you could have arranged a variety of combinations ({1A;2B;3CD},{1A;2BC;3D}, etc.). If we consider the overlap in elements as a scoring metric, something like 1A, 2B, and 3CD would have a score of 2 since only one element (8) overlaps between C and D. However, if we group 1AB, 2C, 3D then …
Topic: clustering
Category: Data Science

How To Download WordPress Audio Attachments

I've been searching high and low trying to figure out how to create download links for audio files uploaded to a post. I know how to display the audio url directly into the theme template, but when it's clicked, it just starts to stream the audio right in the browser. I need a way to prompt the file to download once clicked. Looking for more of a snippet for the functions.php file than a plugin.
Category: Web

Should /wp-includes/js/* folder be blocked in robots.txt file for a WordPress website?

In my WordPress website. I am disallowing /wp-includes/js/* folder in the robots file. Is that bad? I use SEMRush to audit my site and it shows an error that a resource at the above location is being blocked. This is my robots.txt User-agent: * Allow: /wp-content/uploads/ Disallow: /wp-admin/ Disallow: /wp-includes/ Disallow: /wp-content/plugins/ Disallow: /linkout/ Disallow: /recommended/ Disallow: /comments/feed/ Disallow: /trackback/ Disallow: /index.php Disallow: /xmlrpc.php Disallow: /readme.html Disallow: /refer/ Disallow: /search/ Allow: /wp-admin/admin-ajax.php Sitemap: https://www.example.com/post-sitemap.xml Sitemap: https://www.example.com/page-sitemap.xml Sitemap: https://www.example.com/video_portal-sitemap.xml Sitemap: https://www.example.com/press_release-sitemap.xml …
Category: Web

How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?

I would like to add toggle style button near the left sidebar for collapsing and opening/closing the left sidebar of Wordpress default Twenty Fifteen theme. I have this code for only removing the left sidebar: body:before, #sidebar, #colophon, .entry-footer { display:none; } .site-content { margin: 0 auto; float: none; width: 100%; max-width: 1200px; } So how can I also add an arrow for manually opening and closing the left sidebar of twenty fifteen theme? And how to stretch whole site …
Category: Web

How to get a list of all attachements urls for every post of a wordpress installation?

I'd like to retrieve a list of all attachment URLs for all posts of a website. This would bring something like http://example.com/mypost/attachment-1/ http://example.com/mypost/attachment-2/ http://example.com/anotherpost/attachment-deff/ http://example.com/post3/attachment-deff4/ Would it imply to use: wp_get_attachment_url
Category: Web

Updates all internal links on permalink update

Is there a way to update all internal links (in pages, posts, cpt...) when a permalink is updated? Eg: I have a page exemple.com/mypage, and this page is linked in other pages and posts. If for any reason I decide to update the permalink of mypage. All the internal links to this pages are not updated, and if my name is totally different to the previous one, I get 404 errors. I'm thinking about two solutions: Using shortlink in the …
Category: Web

Predictions with arbitrairy sequence length for stateful RNN (LSTM/GRU) in Keras

I have time series data of the following properties: input shape: (num_timesteps, num_features) output shape: (num_timesteps, num_outputs) I reshape it to batch form: input shape: (num_batches, num_timesteps_in_batch, num features) output shape: (num_batches, num_timesteps_in_batch, num outputs) I have a stateful RNN in Keras: modelinput = Input(batch_shape=(num_batches,None,num_features)) prediction = GRU(10,return_sequences=True,stateful=True)(inputs) model = Model(inputs=modelinput,outputs=prediction) After trainig (which works fine) I would like to predict on a sequence without cutting the data, so input shape (num_timesteps, num_features). How can I do that? I thought …
Category: Data Science

key generation from feature vectors in high dimentions

I welcome any suggestions to solve the following hard problem: I have a dataset of float feature vectors of size 512 where each feature vector is extracted from a face image. I want to generate a key given a feature vector (this key can be a number/binary code/etc) that is consistent to each person without comparisons between feature vectors. The only input I have is the given feature vector. for example if I see a photo of me I want …
Category: Data Science

PySpark: How do I specify dropna axis in PySpark transformation?

I would like to drop columns that contain all null values using dropna(). With Pandas you can do this with setting the keyword argument axis = 'columns' in dropna(). Here an example in a GitHub post. How do I do this in PySpark ? dropna() is available as a transformation in PySpark, however axis is not an available keyword. Note: I do not want to transpose my dataframe for this to work. How would I drop the furniture column from …
Category: Data Science

Remove "All categories" from searchbar dropdown

I have been struggling with this and could not find a clear answer online. Will putting a product search bar I have a dropdown visible with all the categories you can search in. I would just like to keep only the categories and remove the "all categories" option. You can see the current search I would like to fix here : https://compare-tech.fr Thank you to anyone who will be able to help :)
Category: Web

Nav Walker that shows only children and siblings of top level parent menu item

I have a nav menu that is structured like this.. Main Section 1 – Child Link 1 -- Grandchild Link 1 – Child Link 2 – Child Link 3 Main Section 2 – Child Link 1 – Child Link 2 – Child Link 3 Lets say that I am on any page within Main Section 1 (including Main Section 1 itself). I want to only show the menu items (and their children) that have Main Section 1 as their parent. …
Category: Web

How to set 'column-primary' to backoffice 2nd column by default

I'm customizing the way custom posts are displayed in the backoffice. I'm trying to shift the section that appear on hover (I'm refering to the four buttons Edit, Quick edit, Trash, Preview) in the first column to the second one. The reason is that the section, even if is hidden, takes up space vertically. It seems that the edit section is assigned to the column that is signed with the class column-primary, so I'd like to assign that class to …
Category: Web

change user password REST API

I am trying to let a user change their password via the API. What it looks like here is that I can send a POST request to the users endpoint with their user ID at the end, sending the new password in the request body as JSON. So, POST to : https://example.com/wp-json/wp/v2/users/123 And in the body: { "password": "mySecretPassword" } In this case, the user is authenticated via JWT and needs to send the token in the header of the …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.