Joms
Forum Replies Created
-
Forum: Developing with WordPress
In reply to: Automatically add CPT category as Nav menu sub itemYou can use the
wp_nav_menu_objects
filter. Try this (haven’t tested it yet):add_filter( 'wp_nav_menu_objects', 'wpg2byt_add_term_parent' ); function wpg2byt_add_term_parent( $items ) { $terms = get_terms( array( 'taxonomy' => 'project', 'hide_empty' => false, ) ); foreach ($terms as $term) { //format its data to be compatible with the filter $link = array ( 'title' => $term->name, 'menu_item_parent' => //id of the parent menu, 'ID' => '', 'db_id' => '', 'url' => get_term_link($term) ); $items[] = (object) $link; } return $items; }
- This reply was modified 4 years, 8 months ago by Joms.
Forum: Fixing WordPress
In reply to: How to edit mobile versionJust looking at the markup of the footer, it consists of two separate menus and the space is intended for a title much like the other menus in the footer. So you either need to combine the two menus so there won’t be a space, or add a title for the second menu. Where to do this depends on the theme – I suggest starting at the Widgets or the Menu itself.
- This reply was modified 4 years, 8 months ago by Joms.
Forum: Developing with WordPress
In reply to: Race conditions for a unique post_titleIt’s actually an insert post:
So I have a generate_invoice_number() function that has this query:
$max = $wpdb->get_var ( 'SELECT MAX(cast(post_title as unsigned)) AS max FROM ' . $wpdb->prefix .'posts AS po WHERE po.post_status IN ("paid", "unpaid", "expired", "credit") AND po.post_type = "' . PPY_INVOICE_PT .'"' ); // code to generate the number based on the max value
And then use it like this:
$number = $this->generate_invoice_number(); $post = array( 'post_title' => $number, 'post_type' => $post_type, 'post_status' => $status ); $new_post_id = wp_insert_post($post);
This works fine until the API that we use charges our users simultaneously (through automatic payments) and so the duplicate issue happens. This is due to multiple executions to the script that may run the select query before another insert has happened.
- This reply was modified 5 years, 5 months ago by Joms.
Add the taxonomy parameter to your function.
function modify_labels( $label,$taxonomy ){ if ( $taxonomy == 'YOUR TAXONOMY HERE' ) { $label = 'New label' } return $label; } add_filter('beautiful_filters_taxonomy_label', 'modify_labels', 10, 2);
Thanks, the way it works though is that the first language file that’s loaded will override the succeeding ones. It’s also right there in the top comment of your method ??
That’s why I suggested
load_plugin_textdomain
since it has a builtin logic to check the languages directory first –// Try to load from the languages directory first. if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) { return true; } if ( false !== $plugin_rel_path ) { $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' ); } elseif ( false !== $deprecated ) { _deprecated_argument( __FUNCTION__, '2.7.0' ); $path = ABSPATH . trim( $deprecated, '/' ); } else { $path = WP_PLUGIN_DIR; }
Cheers
Yes thank you but isn’t that just for vendors and shop managers? What about buyers? For example a buyer with a Pro membership can buy products that are under the Pro category.
Is that possible with the addon or do we need to use a different WooCommerce plugin for that purpose?
P.S. I see in the video tutorial that there is a field for Categories, but I think that’s only for when vendors are creating their products right?
Forum: Fixing WordPress
In reply to: Instead of theme thumbnails only blank squaresAre you using a multilingual plugin? Or do you have 2 separate WordPress installs for each of the languages?
Because it seems like you installed WordPress on
www.dietetykwlondynie.co.uk/en
But your Home and Site URL are set to
www.dietetykwlondynie.co.uk
(as seen on where your stylesheet and images link to)Try updating them by following the instructions here: https://codex.www.ads-software.com/Changing_The_Site_URL`
- This reply was modified 7 years, 2 months ago by Joms. Reason: Added possible solution
Forum: Fixing WordPress
In reply to: Trying to work out how to speed up my site.Your website takes more than 3MB of resources on first load. You are right that the main culprit is the background image that takes around 2.1MB. There’s no amount of caching that could fix it on a new user visiting your website because the browser has to download the image first.
Suggestions:
– You can minimize the size of the image considerably by optimizing it for web use. I just tried it in Photoshop using “Save for Web” and I removed 50% of the file size.
– Change the image to a repeating background image. You may need a designer for this. Basically you use a smaller image that will be repeated to fill the background instead of using a single large image.Forum: Fixing WordPress
In reply to: The webside looks strageYour website’s site URL still points to the .se domain. Since you can no longer login in the admin you will have to update it via FTP or directly into the database.
Here’s a guide on how to update the site url:
https://codex.www.ads-software.com/Changing_The_Site_URLForum: Fixing WordPress
In reply to: How do I Add Google Analytics Code to my Blog?The easiest way is to install an analytics plugin like this one: https://www.ads-software.com/plugins/google-analytics-for-wordpress/
Forum: Fixing WordPress
In reply to: Root out hidden comments?For your Google problem, you can request for a malware review. Follow this guide: https://support.google.com/webmasters/answer/168328?hl=en
As for the wrong comment count it’s probably caused by a comment plugin that messed with the total amount of comments in your database. Try the fix here: https://beerpla.net/2010/03/21/how-to-diagnose-and-fix-incorrect-post-comment-counts-in-wordpress/
The SQL query that you’d want to run (where ‘wordpress’ is your database name):
UPDATE wordpress.wp_posts wpp LEFT JOIN (SELECT comment_post_id AS c_post_id, count(*) AS cnt FROM wordpress.wp_comments WHERE comment_approved = 1 GROUP BY comment_post_id) wpc ON wpp.id=wpc.c_post_id SET wpp.comment_count=wpc.cnt WHERE wpp.post_type IN ('post', 'page') AND (wpp.comment_count!=wpc.cnt OR (wpp.comment_count != 0 AND wpc.cnt IS NULL))
This should help to re-index your website: https://support.google.com/webmasters/answer/6065812?hl=en
Forum: Fixing WordPress
In reply to: Turn off CachingUnfortunately some of my customers are still seeing these errors.
If the errors are only happening to your users can you try logging out as admin? You can also try creating a new user with the subscriber role or whatever the users with problems are assigned to. This could be an existing error and not because of caching. Might be worth looking into ??
Forum: Fixing WordPress
In reply to: Turn off CachingNo you should never edit WordPress core files. WP Cache shouldn’t give you any problems. Do you have a caching plugin installed? Or maybe there’s a server-side caching plugin in your hosting provider?
You can follow this guide: https://codex.www.ads-software.com/I_Make_Changes_and_Nothing_Happens
Forum: Fixing WordPress
In reply to: wp-includes/pluggable.php on line 1228 Blank LoginThe most likely scenario is a plugin / theme issue. Try to remember the last thing that you were working on before the problem manifested. A failed WP automatic update could also be the culprit.
You can follow the troubleshooting tips here: https://codex.www.ads-software.com/Common_WordPress_Errors