Menu
  • HOME
  • TAGS

How can I change link in my dropdown menu [closed]

php,wordpress

One solution is to load all the drop downs, and use Jquery to hide them. Next you could display then based on $(document).ready(function(){ $(".subdropdown").show(); }); if($(".dropdown1").val()==item-2){ $(".subdropdown").show(); } Hope this helps, this is just an example buy i hope you can expand from this ....

Passing variables from PHP to Javascript with wp_localize_script function

ajax,wordpress,wordpress-plugin

The issue is that $someone is not within the scope of your function. You can import it into the scope, by declaring it as global and then accessing it: global $someone; $someone = 'whatever'; function admin_script_style($hook) { global $someone; // $someone is now accessible ... } Note that, you don't...

Wordpress log out using URL and redirect to specify page

javascript,php,wordpress

Try wp_logout() function use the funtion . if($_GET['logout'] == 1) { ob_start(); error_reporting(0); wp_logout(); $redirect = wp_logout_url(); wp_safe_redirect( $redirect ); } ...

Redirect based on operating system

javascript,wordpress,redirect,user-agent

Use user agent instead, because appVersion is deprecated. function detectOS(){ if (navigator.userAgent.indexOf("Win")!=-1) return "Windows"; if (navigator.userAgent.indexOf("Mac")!=-1) return "MacOS"; if (navigator.userAgent.indexOf("Linux")!=-1) return "Linux"; if (navigator.userAgent.indexOf("OpenBSD")!=-1) return "OpenBSD"; if (navigator.userAgent.indexOf("FreeBSD")!=-1) return "FreeBSD"; if (navigator.userAgent.indexOf("NetBSD")!=-1) return "NetBSD"; return undefined; } ...

Wordpress function to effect only one (custom) post type, and not every post

wordpress,custom-post-type

You're looking for get_post_type(): function custom_default_cover_image( $image = null, $args = null ) { global $post; if ( get_post_type() === 'job_listing' && ! $image ) { $image = array( 'http://website.com/image.jpg' ); } return $image; } add_filter( 'cover_image', 'custom_default_cover_image', 10, 2 ); ...

How to fetch the page id and use it for an image name

php,wordpress

<?php $postid = get_the_ID() ?> <div class="splash"> <img src="<?php echo get_template_directory_uri(); ?>/images/<?php echo $postid;?>.jpg" /> </div> ...

Display wordpress posts in ascending order

php,wordpress,templates

It's ok but, $wp_query->query('showposts=24&post_type=movie&order=ASC' . '&paged=' . $paged); The difference is: "order", not "orderby"....

Hacked WP, regex link removal

regex,wordpress

Assuming the width and height will always be negative, and that the content within the offending <div/> snippets don't have any inner <div/> snippets: s/<div style="position:absolute; left:-\d*px; top:-\d*px;">.*?<\/div>//g Here's the regex in play: https://regex101.com/r/eV1kN7/1...

Changing font-size of
  • on wordpress
  • css,wordpress,html-lists

    I think you have style inheritance from upper element, check it with dev. tools in browser. You can also try to set inline style for: <li style: "font-size: 22px;">Name 1</li> or add !important in your css file, like this: td > ul li { font-size: 22px !important;"> } ...

    CSS mystery: why the extra height in my div's?

    javascript,css,wordpress

    Adam Maybe you just remove the blank <p></p> that you really don't need it. remove that <p></p> after the <img/>. And your layout will be good. Take a look(which <p></p> you should remove it.)...

    How to exclude posts without featured images from custom post type WP_Query

    wordpress,wp-query

    Do a meta_query where you search for _thumbnail_id: $args_projekte = array( 'post_type' => 'projekt', 'posts_per_page' => 18, 'post__not_in' => array(191), 'orderby' => 'rand', 'meta_query' => array(array('key' => '_thumbnail_id')) ); $query_projekte = new WP_Query($args_projekte); The above verifies that the _thumbnail_id key exists....

    How to hide the help button from the dashboard of wordpress?

    css,wordpress

    Try this add_filter( 'contextual_help', 'mycontext_remove_help', 999, 3 ); function mycontext_remove_help($old_help, $screen_id, $screen){ $screen->remove_help_tabs(); return $old_help; } ...

    If image is null from JSON, use another image - AngularJS

    json,angularjs,wordpress,angularjs-ng-repeat,wp-api

    You can use ng-style: <article ng-repeat="post in posts"> <div ng-style="post.featured_image.attachment_meta.sizes.medium.url === null ? {'background-image': 'url(/yourimage.jpg)' } : {'background-image': 'url('+post.featured_image.attachment_meta.sizes.medium.url+')' }"></div> </article> ...

    Change the Path of wordpress featured image

    wordpress

    The image you're referring to isn't an attachment image...it's a theme asset. If you're properly including this in your template, changing hosts won't be a problem and the URL will automatically update. The following is an example of how you could be including the src in your template, using get_stylesheet_directory_uri():...

    How to remove the quantity field from cart page for specific product attribute WooCommerce

    php,wordpress,woocommerce

    $attributes = $product->get_attributes(); only returns an array of the product's attributes, so you would at least need some kind of conditional logic as returning the attributes alone would not be enough. If you notice this line: echo apply_filters( 'woocommerce_cart_item_quantity', $product_quantity, $cart_item_key ); You don't need to override the cart.php template...

    What does the $wp_did_header do in wordpress?

    php,wordpress

    It's a global variable that can be used to check whether or not WordPress has already sent headers.

    Wordpress - customized pages with blocks - prohibit google seo index of blocks

    wordpress,seo,woocommerce,robots.txt,google-sitemap

    Noindex tags would be useful. https://support.google.com/webmasters/answer/93710?hl=en

    How to seperate wordpress header navigation into side to side by edition Php files?

    php,css,wordpress,header,navigation

    Try this and put the css .fullWidth{ width : 100%; margin : 0 auto; } .leftClass{ width : 75%; float : left; } .rightClass{ width : 25%; float : right; } add class in div tag <nav class="navbar navbar-default" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"> <span...

    Wordpress thumbnail grid expanding preview

    javascript,jquery,wordpress

    Here is one way you could do it. By creating a short code in your functions.php file, you can include the js resources you need. Please note for this implementation, you must include the resources locally as defined on this line: element.src = '/wp-content/themes/custom_name_space/js/$src'; Or You can use some kind...

    Wordpress on IIS with shared wp-content

    php,wordpress,iis,permissions

    Assuming: +-----------+ +----------+ | Server A | <-- | Server B | +-----------+ +----------+ First, lets look at the App Pool for Server A -> Site A and Server B -> Site B. I would advise using Impersonation versus a service account. This will allow you to leverage AD or...

    Find and print the host name of the mysql in wordpress

    php,mysql,wordpress,hostname

    You can use $_SERVER['HTTP_HOST'] For http://localhost/velocity/wordpress/?page_id=4 it will return http://localhost...

    woocommerce thumbnails have different image widths in chrome and mozilla

    html,css,wordpress,google-chrome,mozilla

    Having to override default styles is one of the reasons I hate Bootstrap... image HTML has a width/height 180px180px... but there is a conflict between parent container for image woocommerce-layout.css #single-product div.thumbnails a { width: 100%; } .woocommerce #content div.product div.thumbnails a, .woocommerce div.product div.thumbnails a, .woocommerce-page #content div.product div.thumbnails...

    Coding after Wordpress loop not showing

    php,wordpress

    I'm not sure what you're doing with this line... <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('commissions-intro')) ?> ...since you're not outputting anything. I'd either get rid of it, or fix it so that it's a valid conditional (with an endif;). It also looks like you're calling get_footer() twice......

    Wordpress plugin ajax returns 0

    javascript,php,jquery,ajax,wordpress

    Below code worked perfectly fine for me: <?php global $wpdb; global $wp_version; $results = $wpdb -> get_results( " SELECT ID, post_title, post_excerpt FROM $wpdb->posts WHERE post_type = 'post' and post_status NOT LIKE 'auto-draft' AND post_title NOT LIKE 'Auto Draft' AND post_status = 'publish' ORDER BY post_title " ); ?> <div...

    Redirect 301 with wordpress articles from a domain to another

    wordpress,.htaccess,redirect

    You can use mod_rewrite for this: RewriteEngine On RewriteRule ^(\d+)/(\d+)/(\d+)/([\w\-]+)/?$ http://www.newdomain.com/$1/$2/$3/$4/ [R=302,NC,L] If you are happy with the redirect, and would like to make it permanent, you can change 302 to 301....

    Wordpress Custom Post type archive display

    wordpress,templates,custom-post-type,advanced-custom-fields

    you are guessing right, first you need a page template where you are going to call your terms, but you need to call by his taxonomy, right?, To do that, you need to use the function get_terms( $taxonomies, $args );, and with the function get_term_link($term), you are going to obtain...

    Remove frameborder in avada theme in youtube shortcode?

    wordpress,themes,shortcode

    Shortcode comes in fusion core plugin. fusion-core/shortcodes.php findout add_shortcode('youtube', 'shortcode_youtube'); remove frameborder from div under above shortcode....

    need wordpress plugin to show 3 type of different kind of text, image and 2 buttons

    wordpress,plugins,wordpress-plugin

    Your question is not really understandable, but I think you are looking for this, it's a really good slider with a lot of functionality. Revolution Slider...

    How to add sidebar at single.php in Wordpress

    wordpress

    The most logical reason for this to happen is that there isn't enough room for both the main content and the sidebar to appear next to each other. Check the width of your sections in your stylesheet and make the necessary changes to the styles.

    How to run PHP through Adobe Muse generated CSS

    php,html,css,wordpress,muse

    I would avoid having PHP process your entire CSS file, especially in WordPress. Because: WordPress will have to be loaded in every request to that CSS file. That is a lot of overhead for what you need to do. Depending on how dynamic the content you plan on putting in...

    Excluding certain pages from being redirected to https

    wordpress,.htaccess,redirect,https,http-redirect

    Try using THE_REQUEST instead of REQUEST_URI: <IfModule mod_rewrite.c> RewriteEngine On # Go to https if not on careers RewriteCond %{SERVER_PORT} =80 RewriteCond %{THE_REQUEST} !/careers/[\s?] [NC] RewriteRule ^(.*)$ https://www.mywebsite.com/$1 [R,L] # Go to http if you are on careers RewriteCond %{SERVER_PORT} !=80 RewriteCond %{THE_REQUEST} /careers/[\s?] [NC] RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R,L] </IfModule>...

    Add second single product page in Woocommerce

    wordpress,woocommerce

    What I would do in this case is add a link that will reload the page with a custom query arg in the URL. Then you can filter the template via template_include to load a different template. Untested, so be careful of syntax typos. add_filter( 'template_include', 'so_30978278_single_product_alt' ); function so_30978278_single_product_alt(...

    Contact Form 7 SMS integration with twilio

    wordpress,sms,contact-form-7

    You can hook yourself in to the CF 7 process. Have a look here, here and here for more information and some examples on how to do it. Hooking into where/after the mail is sent might be interesting for what you want to do....

    login with username or email in wordpress

    wordpress

    Try this remove_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 ); add_filter( 'authenticate', 'tcb_authenticate_username_password', 20, 3 ); function tcb_authenticate_username_password( $user, $username, $password ) { if ( ! empty( $username ) && is_email( $username ) ) : if ( $user = get_user_by_email( $username ) $username = $user->user_login; endif; return wp_authenticate_username_password( null, $username, $password );...

    Woocommece login URL

    wordpress,woocommerce

    Try this code: function redirect_login_page(){ if(is_user_logged_in()){ return; } global $post; // Store for checking if this page equals wp-login.php // permalink to the custom login page $login_page = get_permalink( 'CUSTOM_LOGIN_PAGE_ID' ); if( has_shortcode($post->post_content, "woocommerce_my_account") ) { wp_redirect( $login_page ); exit(); } } add_action( 'template_redirect','redirect_login_page' ); ...

    .htaccess - 301 redirect where the URL structures aren't identical

    regex,wordpress,.htaccess,mod-rewrite,redirect

    The way you are trying to capture substrings and inject them into the substitution string is totally wrong. Try this: RewriteRule ^([A-Za-z0-9\-]+)/([A-Za-z0-9\-]+)/(\d*)/?$ http://localhost/ats-new/$1/$2-$3 [R=301,NC,L] ...

    Strange error when developing a Wordpress theme

    php,html,css,wordpress

    You have a broken link tag in your header.php file. Change this: <link rel="stylesheet" href="<?php bloginfo('stylesheet_url')?>" To: <link rel="stylesheet" href="<?php bloginfo('stylesheet_url')?>"> While this corrects the issue at hand I'd advise you to find a different tutorial. There are multiple issues with the approach you're taking such as including stylesheets in...

    Foundation and Wordpress blank spaces

    wordpress,zurb-foundation

    the reason this happens is that your tiles does not have equal height. you can use Foundation Equalizer to fix that. and leave the code has you have it. I would still change the large to small and have <article class="small-12 medium-6 large-4 columns"> to achieve better responsive results. Foundation...

    WordPress expanding grid with thumbnail

    javascript,css,wordpress,grid,expand

    Please have al look at your code: data-largesrc="images/1.jpg" Change this to your thumbnail url....

    Woocommerce Return False with message

    php,wordpress,woocommerce

    You can have a $message variable that is empty for true and contains a messages (in HTML) for false: PHP $message = ""; ... function disable_cart_for_over_fifty_k( $purchasable, $product ){ global $message; if( $product->get_price() >= 50000 ) { $message = "<p class='errorMessage'>This product is over £50,000 - please contact us</p>"; return...

    Custom wordpress function not showing the right number of posts

    php,wordpress

    maybe because only 2 posts ( of the last 5 posts that you actually call ) got get_field('featured-pika-recipe') == 'Yes' you can try to add this custom field directly to your query to get last 5 posts with this custom field with following code 'meta_key' => 'featured-pika-recipe', 'meta_value' => 'Yes'...

    Changing DOMNode tag name creating anomalies within the saved HTML

    php,wordpress,dom

    Solution You have to traverse the node list backwards in order to make the kind of changes I want to do. crnix's answer helped identify that the problem occured with replaceChild within the change_tag_name function. Changing my foreach loop to the following fixed my issue: $sections = $doc->getElementsByTagName('p'); $i =...

    Gravity Forms - Show link after submission

    javascript,jquery,wordpress,forms

    It turns out I found the appropriate event: $(document).bind('gform_confirmation_loaded', function() { //Do stuff }); ...

    How can I add a field only if it is completed?

    php,html,wordpress

    Explaining if (isset($web) && $web != ""): isset($web) checks if $web is set (exists as a php variable) and it is not NULL, but it could be blank ($web = "";). && means AND. $web != "" check if $web (after checking if $web is set) is not blank (like...

    Trying to fill a SVG map from wordpress custom categories

    wordpress,dictionary,svg

    Using the Advanced Custom Fields plugin, you can add custom fields to categories (“taxonomy terms” in WP lingo) as well. And the get_field function provided by the plugin allows you to query the value of such a field for every object you might have attached it to – you just...

    How can I set the Image of woocommerce category as the background of the category title? [duplicate]

    php,html,wordpress,woocommerce

    <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?> <h1 style="background: url(<?php if ( is_product_category() ){ global $wp_query; $cat = $wp_query->get_queried_object(); $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); echo "'{$image}'"; } ?>);" class="page-title"><?php woocommerce_page_title(); ?></h1> I followed How to display Woocommerce Category image? and...

    Text-decoration/CSS causing text to move

    html,css,wordpress

    This is normal behaviour: Bold text is wider, thus repositioning the centered text around it. You could go for a fixed width on all links to prevent this: .main-navigation a { text-decoration: none; min-width: 6em; display: inline-block; } ...

    WooCommerce seems to only orderby date and not price

    php,ajax,wordpress,woocommerce

    Try this: $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'beast-balls', 'orderby' => 'meta_value_num', 'meta_key' => '_price', 'order' => 'asc' ); ...

    How to enable mod_rewrite on Apache 2.4?

    php,wordpress,apache,mod-rewrite,centos7

    i found the way to know if a module is loaded or not, here's to command to list the modules enabled: apachectl -M | sort It will list all enabled modules alphabetically. Wordpress has an .htaccess but default where it enables Rewrite_Mod for its use: # BEGIN WordPress <IfModule mod_rewrite.c>...

    How to remove lines of code in a Wordpress child theme?

    php,wordpress

    im not sure i understand the issue correctly, have you set up a child theme ? If so, the child themes functions are loaded before the parent themes allowing you to overwrite the parent functions that are wrapped in: if (!function_exists('myfunction')) { function myfunction(){}; } Which is basically saying, if...

    WooCommerce: How to display Category Name in single-product.php

    php,wordpress,woocommerce

    Try this : global $post; $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as $term) { echo $term->name .' '; $thumbnail_id = get_woocommerce_term_meta( $term->term_id, 'thumbnail_id', true ); $image = wp_get_attachment_url( $thumbnail_id ); echo "'{$image}'"; } ...

    How to call posts from PHP

    php,wordpress,caching,cron,call

    The easiest way to do it in PHP is to use file_get_contents() (fopen() also works), if the HTTP stream wrapper is enabled on your server: <?php $postUrls = array( 'http://my.site.here/post1', 'http://my.site.here/post2', 'http://my.site.here/post3', 'http://my.site.here/post4', 'http://my.site.here/post5', ); foreach ($postUrls as $url) { // Get the post as an user will do it...

    How to crop image from center using wp_image_editor

    wordpress,image,wordpress-plugin,resize-crop,wp-image-editor

    Try this code: $crop = array( 'center', 'center' ); resize( $max_w, $max_h, $crop); ...

    Creating complex queries with WP_Query in Wordpress

    wordpress,wp-query

    Your meta_query is completely wrong. All you parameters inside your arrays is invalid. post__not_in should be outside your meta_query meta_key, meta_value_num and meta_compare are all invalid paramters inside a meta_query. This parameters is used outside a meta_query You query should look something like this $args_projekte = array( 'post_type' => 'projekt',...

    How To check Product Have Variation in woocommerce

    php,wordpress,woocommerce,product

    This should work: if( $product->is_type( 'simple' ) ){ // No variations to product } elseif( $product->is_type( 'variable' ) ){ // Product has variations } Example: If you will replace the file woocommerce --> single-product --> meta.php with this code, you will see it works. <?php /** * Single Product Meta...

    Random opening tabs/pills - bootstrap 3

    javascript,css,wordpress,twitter-bootstrap-3

    use this code : var items = $('[data-toggle=pill]'); var i = parseInt(Math.floor(Math.random()*items.length)); $('#tabs a:eq(' + i + ') ').tab('show'); ...

    How to use curl return value in php script

    php,wordpress,curl,login

    custom_login.php is not returning any output. You can test this by going to example.com/custom_login.php?username=theUsername&password=thePassword. You can change this by simply echoing what you want to use: if ( is_wp_error( $user ) ) { echo 0; return; } else { echo 1; return; } Edit: As @unknown pointed out you generally...

    Empty email data when I send an AJAX contact form from Wordpress

    php,jquery,ajax,wordpress

    I would modify your data to the following, so that the action is explicitly set in datos: var datos = { "nombre" : $('#nombre').val(), "email" : $('#email').val(), "telefono" : $('#telefono').val(), "mensaje" : $('#mensaje').val(), "action": 'sendcontacto' }; $.ajax({ url: ajaxurl, type: 'POST', data: datos, ...

    How to display grouped products in a list with quantity in woocommerce?

    wordpress,woocommerce

    You can read about WooCommerce's template overrides. If you aren't seeing the default with your theme that means that your theme is overriding it. I can't be sure, but probably you need to go into your theme's woocommerce folder.... and find the grouped.php template in: yourtheme/woocommerce/single-product/add-to-cart/grouped.php and rename it to...

    How to use prepare() with dynamic column names?

    php,sql,wordpress,prepared-statement

    You could use a list of "approved" values instead, that way you're not really using user data inside a query. Something like this: $Approved = array ('firstname', 'lastname', 'birthdate') ; $Location = array_search($ColumnName, $Approved) // Returns approved column location as int if($Location !== FALSE) { // Use the value from...

    Wordpress links don't work

    php,wordpress

    This problem occurs if mod_rewrite function is not probably working on the server, in this case you can simply overwrite this issue by manually editing the .htaccess file. It should look like this: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule...

    Bxslider, Custom Fields & Wordpress

    php,wordpress,bxslider

    First, you can run array_filter() on the $ar array to remove false/ empty values. Next, you probably don't need this line $media_full = wp_get_attachment_image_src($image_id, "full", false); You could comment it out and it won't have any effect on the page....

    PHP $wpdb Select?

    php,mysql,wordpress,select

    wrap ip address passed to mysql with single quotes, use actual table name. if your resulting array is blank, then you are missing that ip from your table.

    $wpdb returns duplicate posts

    php,wordpress,wpdb

    Nevermind, I solved it on my own. While reading on the WordPress Codex for $wpdb, I saw that if I use OBJECT_K it will remove the duplicates and that solved my problem. If it helps anyone, here is my working code: function latest_posts_after_last_login( $atts ) { global $wpdb, $current_user; $atts...

    How can merge two arrays values in one array and save in database

    php,arrays,wordpress,meta-key

    When you are saving the multidimensional array you can use this code: $product_img_path[$count]['wpc_resize_thumb_img'] = $upload_dir['url'].'/'.$resize_img_name; $product_img_path[$count]['wpc_resize_bid_img'] = $upload_dir['url'].'/'.$resize_big_img_name; update_post_meta($post->ID, 'wpc_images', $product_img_path); That way you can get multidimentional array like you want: Array ( [1] => Array ( [wpc_resize_thumb_img] => http://localhost/test/wp-content/uploads/2015/06/Wallpaper_55-212x159.jpg [wpc_resize_big_img] =>...

    Wordpress and Xampp not open child pages

    php,wordpress,xampp

    By default, Xampp has FollowSymlinks disabled. See point 4 on how to enable mod rewrite (if not done already) set AllowOverride from none to all https://codex.wordpress.org/Using_Permalinks#Fixing_Permalink_Problems If AllowOverride is not set to all, permalinks will cause exactly these 404 errors you describe ("Not found" on existing pages). ...

    wpdb - add up values for custom field within a specific category

    php,wordpress,wpdb

    Sounds like you need a subquery. In SQL, you want something like this: SELECT sum(meta_value) from wp_postmeta WHERE meta_key = "points" AND post_id in (SELECT object_id from wp_term_relationships WHERE term_taxonomy_id = 6) AND post_id in (SELECT post_id from wp_postmeta WHERE meta_key = "cf_Category" and meta_value = "Chapter Building") The inner...

    WordPress show current page submenu

    javascript,jquery,css,wordpress

    use .header-menu .current-menu-item ul.sub-menu { display:block; } and .header-menu .current-menu-item{ height:auto } to remove the overlap. Fidddle: http://jsfiddle.net/ghnd4ae3/2/...

    Wordpress page can't continue due to this error

    php,css,wordpress,wordpress-plugin,wordpress-theming

    First error is a general server error (look for http 500 status code). It's very unspecific so it you could look up in your server logs fore more information. Second error occurs because the font url can't be reached - try it for you self and open the url of...

    Wordpress - loadin admin.css at last

    css,wordpress

    Try this code . This will load admin-style.css in the backend add_action( 'admin_enqueue_scripts','admin_styles',10 ); function admin_styles() { wp_register_style( 'custom_admin_css', get_template_directory_uri() . '/admin-style.css', false, '1.0.0' ); wp_enqueue_style( 'custom_admin_css' ); } ...

    getElementById with an array Javascript

    javascript,jquery,arrays,wordpress

    getElementById is only defined on document. There is no need to be able to call it on an element, since IDs are supposed to be unique throughout the document. Having multiple elements with the same ID inside a document is invalid. If you really have multiple elements with the same...

    woocommerce - make order notes required

    wordpress,woocommerce

    Change the action from 'woocommerce_checkout_process' to 'woocommerce_after_checkout_validation'. add_action('woocommerce_after_checkout_validation', 'my_custom_checkout_field_process'); function my_custom_checkout_field_process() { // Check if set, if its not set add an error. if ( ! $_POST['order_comments'] ) wc_add_notice( __( 'Please enter something into this new shiny field.' ), 'error' ); } ...

    Wordpress Custom Post Type categroies

    wordpress,custom-post-type,advanced-custom-fields

    You can do that with Post Types UI, You will need to create a new taxonomy. Here is the screenshot explaining that https://s.w.org/plugins/custom-post-type-ui/screenshot-4.png?r=1180724 Just fill the text boxes with appropriate names, and check STORY under "Attach to Post Type" option. After that you will have custom taxonomy like "Story Category"...

    How to Extract Part of a String In JavaScript

    javascript,jquery,string,wordpress

    No need for string manip, use the removeClass method: $('.icon-option i.selected').removeClass("selected"); If you then also need the string of the class names you can expand to: $('.icon-option i.selected').removeClass("selected").attr("class"); ...

    How do I check if items in a array are present in a string php

    php,arrays,wordpress

    Try this, check if strpos doesn't return false: foreach($bads as $bad) { if (strpos($string, $bad) !== FALSE) { echo "True"; exit; } else { echo "Not True"; } } ...

    Can't select the current database name

    php,mysql,sql,database,wordpress

    The WordPress database name is already stored as a constant in a standard wp-config.php. You can access it with DB_NAME. <?php $database_name = DB_NAME; ?> ...

    Reactivating WordPress Jetpack plugin throws an error

    wordpress,jetpack

    This solution worked for me: Deactivate and Delete Jetpack plugin Go to your PHPMyAdmin Run the SQL Query : SELECT * FROMwp_optionsWHEREoption_nameLIKE '%jetpack_%' Delete the items that start with the option_name jetpack_ Download and Install Jetpack. You should now be able to connect JetPack without any errors. ...

    Can not link the author

    wordpress

    Try this : <a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author(); ?></a> ...

    Hide 'show more' button using AJAX

    javascript,php,jquery,ajax,wordpress

    Check this functions.php function buttonHide() { $posts_count = wp_count_posts()->publish; if ($posts_count <= 2) { $result['type'] = "success"; $result['status'] = 'hide' ; $result = json_encode($result); echo $result; die(); }else{ $result['type'] = "success"; $result['status'] = 'show' ; $result = json_encode($result); echo $result; die(); } die(); } add_action('wp_ajax_buttonHide', 'buttonHide'); add_action('wp_ajax_nopriv_buttonHide', 'buttonHide'); add_action( 'init',...

    Custom Loop Pagination in Wordpress

    wordpress,pagination,custom-post-type

    I am assuming you've definded $location_query like this $location_query = new WP_Query($args);, now in your args add posts_per_page => 10. This will split your results in 10 items per page. If your pagination doesn't show new items on the next page make your query like this: $paged = (get_query_var('paged')) ?...

    Conditional text for certain categories within taxonomy.php

    wordpress,conditional,archive,taxonomy,easy-digital-downloads

    You should use is_tax() for this if ( is_tax( 'download_category', 'test' ) ) { echo 'The term page you are viewing is called Test'; } You can also use get_queried_object(). Just do a var_dump() and inspect the output var_dump( get_queried_object() ); ...

    ACF Multiple Map Markers

    wordpress,google-maps,google-maps-api-3,acf

    You can create a custom query and loop through all locations. var locations = [ <?php $args = array( 'post_type' => 'your_post_type', 'posts_per_page' => -1 ); $locations = new WP_Query($args); if($locations->have_posts()){ while($locations->have_posts()){ the_post(); $loc = get_field('location') ?> ['<?php echo get_the_title(); ?>', <?php echo $loc[0]; ?>, <?php echo $loc[1]; ?>], <?php...

    BeautifulSoup: Parsing bad Wordpress HTML

    python,html,regex,wordpress,beautifulsoup

    At least, you can rely on the tag names and text, navigating the DOM tree horizontally - going sideways. These are all strong, p and span (with id attribute set) tags you are showing. For example, you can get the strong text and get the following sibling: >>> from bs4...

    String indices must be integers, new to python

    python,wordpress

    You're getting that error because "string indices must be integers, not str". formats += '\n' + x['name'] + " " + str(i) Here, you are accessing the 'name'th element of x, where 'name' is of course a string and x is a string too, since server.wp.getPostFormats obviously returns a list...

    Query based on custom field

    wordpress,wordpress-theming,advanced-custom-fields,wpdb

    Try using WP_Query over a direct mysql query. https://codex.wordpress.org/Class_Reference/WP_Query In your WP_Query arguments include the 'meta_key' and 'meta_value' parameters. $args = array( 'meta_key' => 'school', 'meta_value' => 'arts' ); ...

    Wordpress list category in custom post type

    php,wordpress,custom-post-type,categories

    You can use wp_get_post_terms: <?php $taxonomy = 'resource-category'; $tax_terms = wp_get_post_terms($post->ID, $taxonomy, array("fields" => "all")); foreach ($tax_terms as $tax_term) { echo '' . '<a href="' . esc_attr(get_term_link($tax_term->term_id, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a>&nbsp;&nbsp;&nbsp; ';...

    Wordpress End If Statements

    php,wordpress,woocommerce

    <?php if ( sizeof( $woocommerce->cart->cart_contents ) == 0 ) { // The cart is empty } else { ?> <div class="header-cart-inner"> <a class="cart-contents" href="<?php echo WC()->cart->get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->cart_contents_count ), WC()->cart->cart_contents_count ); ?> - <?php echo...

    First getElementsByTagName() returns all elements in HTML (Strange behaviour)

    php,wordpress,dom

    METHOD 1 As to use exactly your code, I have done some changes to make it working. If you will print out each $p you will be able to see first element will contain all your HTML. The simplest solution is to add a blank <p> before your HTML and...

    jQuery click event search bar

    javascript,jquery,wordpress

    Remove the relevant .click event, and display: block the main search bar container in the CSS. (this should be enough to get you there) 1.) Remove the jQuery related to search bar show functionality. (eg. click event(s)). 2.) Alter .css file where search elements are display:none; or display:hidden; if a...

    Two language site in wordpress what i can do [on hold]

    wordpress

    You want to look into the WPML plugin. Also, any time you emit a string from your own PHP code, you'll want to use the PHP gettext() method, which makes the string localizeable and will allow you to localize it using WPML. You may also want to modify your WordPress...

    Slider misbehaving

    css,wordpress,wordpress-plugin-dev

    I've figured out somehow .shiftnav-wrap { margin-top: -1px; /* thank you very much @zgood, logotext / menu is not jiggling anymore :) */ } html { overflow-x: hidden; /* adding this line to hide the horizontal scrollbar that appear on slider closing phase */ } #scroll_totop { top: 850px; /*...

    wp_schedule_event hook sheduled but not working

    php,wordpress,cron,wordpress-plugin,cron-task

    Try to move add_action outside of a function: function starthere(){ if (!wp_next_scheduled('my_hourly_event')) { wp_schedule_event( time(), 'hourly', 'my_hourly_event' ); } } add_action( 'my_hourly_event', 'Download_CSV_with_args' ); function Download_CSV_with_args() { wp_mail('[email protected]', 'Automatic email', 'Cron works!'); } ...

    Store posts data according to timestamps in array

    php,arrays,wordpress

    Try to change this line $eventHTML[] = array( $post_unix_timestamp => array( $post ) ); with this line $eventHTML[$post_unix_timestamp][] = $post; ...

    Display Popup when text is clicked in wordpress

    wordpress,text,popup,wordpress-plugin

    Hi you can used bootstrap modal popup. as like demo <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/> <!-- Button trigger modal --> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal"> Launch demo modal...

    Nivo Slider custom height/width problems

    html,css,wordpress,wordpress-plugin,nivo-slider

    If I understand correctly what you want to achieve is something like this (uncommenting /*overflow: hidden;*/): DEMO HTML: <div> <img src="http://i.imgur.com/cjgKmvp.jpg"/> </div> CSS: div{ position: relative; margin: 100px auto; width: 400px; height: 300px; border: 3px solid red; /*overflow: hidden;*/ } img { position: absolute; top: 50%; left: 50%; -webkit-transform: translateX(-50%)...

    Basic trouble with PHP - Line shift

    php,css,wordpress

    Try this .frontfeatured-image img{ float: left; } ...

    Run AJAX function on form submit button after javascript confirm() cancel

    javascript,jquery,ajax,wordpress,forms

    Dont use one(it will fire ajax submit or button click only once) , use here var IsBusy to check user is not repeatedly pressing the form submit, Try below code, var isBusy = false; //first time, busy state is false $('#publish').on('click', function (e) { if(isBusy == true) return ; //if...

    How to add stripslashes to get_option()

    regex,wordpress,wordpress-theming,sublimetext,stripslashes

    Why not just create your own function in place of get_option() (but which takes advantage of it)? For example, you could define the following in functions.php: function my_stripslashes_function($option, $default = false) { return stripslashes( get_option($option, $default) ); } And then use Sublime to replace all instances of get_option with my_stripslashes_function...no...

    CSS disable horizontaly scrolling - Wordpress [on hold]

    php,html,css,wordpress,responsive-design

    Try This: in your css @media only screen and (max-width: 479px){ .post-container{overflow: hidden;} } ...