Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

dbruning22 on "WooCommerce Variation Price"

$
0
0

Any help would be greatly appreciated, been stuck with this for a couple of days now!

On WooCommerce I have a few products, each product has 5 or so variations and there is a price difference with each variation. What I'm trying to achieve is from the drop-down list of variations, is to show the actual price for that variation next to it.

I've done some searching and found this:

add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );

function display_price_in_variation_option_name( $term ) {
global $wpdb, $product;

$result = $wpdb->get_col( "SELECT slug FROM {$wpdb->prefix}terms WHERE name = '$term'" );

$term_slug = ( !empty( $result ) ) ? $result[0] : $term;

$query = "SELECT postmeta.post_id AS product_id
FROM {$wpdb->prefix}postmeta AS postmeta
LEFT JOIN {$wpdb->prefix}posts AS products ON ( products.ID = postmeta.post_id )
WHERE postmeta.meta_key LIKE 'attribute_%'
AND postmeta.meta_value = '$term_slug'
AND products.post_parent = $product->id";

$variation_id = $wpdb->get_col( $query );

$parent = wp_get_post_parent_id( $variation_id[0] );

if ( $parent > 0 ) {
$_product = new WC_Product_Variation( $variation_id[0] );
return $term . ' (' . woocommerce_price( $_product->get_price() ) . ')';
}
return $term;
}

This works great, but the problem I'm having is that it only works with variations where there are no spaces in the variation name: "green", "blue" and so on, but as soon as there's any spaces in the variation name, it stops working: "Green Shirt", "Black Speakers" and so on.

Any help would be greatly appreciated!


DavyJohnes on "Custom taxonomy editor form"

$
0
0

I've created custom taxonomy (for example "people") and I want to remove or rename "Description" field that is existed by default in terms editor (in admin pages). How can I do that? Does action or filter that triggered before render taxonomy editor UI exist?

slicesofamerica on "Add and Average Custom Fields"

$
0
0

I'm creating a music review website. For each album, there are 7 criteria, each set up as its own custom field. How can I add these and divide by 7 to get the average? I would also like to display the average. Don't know where to begin! I am currently doing the math by hand.

http://taylorlasseigne.com/albums/atlas/

slobizman on "Control comments settings (moderation/# on page) per page/post"

$
0
0

I'd like to control various comments settings PER PAGE/POST. Things like this:

- moderated or not
- number of comments per page

Surprisingly since I think it would be valuable, I have not found a plugin for this, or even anyone's function. Does anyone know of something that does this?

AThomas92 on "Change position of a Custom Post Type menu item within a plugin admin menu?"

$
0
0

Hi,

I'm writing my first plugin (my first proper one anyway) and I've created a custom post type called programs. I've managed to get the custom post type menu item nested with the plugin admin menu, but I can only get it to display as the first item, which isn't how I'd like it.

So at the moment the menu is rendering like this:

  • My Plugin
    • Programmes
    • Dashboard
    • Applications

Whereas I'd like it to look like this:

  • My Plugin
    • Dashboard
    • Programmes
    • Applications

Here are my arguments for the custom post type:

$args = array(
    'label'               => __( 'programmes', 'MyPlugin' ),
    'description'         => __( 'Programmes for application from partner organisations', 'MyPlugin' ),
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
    'taxonomies'          => array( 'programmes_categories' ),
    'hierarchical'        => true,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => 'MyPlugin',
    'show_in_nav_menus'   => false,
    'show_in_admin_bar'   => false,
    'menu_position'       => 2,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => true,
    'publicly_queryable'  => false,
    'capability_type'     => 'post'
);

Any ideas?

Thanks in advance,

Ash

TeqToo on "Disable Author Delete media"

$
0
0

I want the client I've created a website for, and to whom I have given limited powers as "Author" through the User Role Editor plugin to be able to upload media files to the media library, but NOT to be able to delete files already in there. The media library contains all the image files for the whole website!

I found this post from a year ago: http://wordpress.org/support/topic/how-to-disable-media-delete-in-wordpress?replies=2. It sounds like this solution is exactly what I'm looking for, but I don't know where to place this bit of code. Is it in functions.php or elsewhere?

SFGolfer on "Access database outside of WordPress 3.9"

$
0
0

I have been using the code below in a custom .php file outside of WordPress. The code worked without any issues until upgrading to 3.9 or 3.9.1.

define( 'SHORTINIT', true );

require_once( $_SERVER['DOCUMENT_ROOT'] . '/blog/wp-load.php' );

global $wpdb;
$tourney = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM database WHERE player_name='".$player."' And season='".$season."' And status='' ORDER BY date DESC", $null ), ARRAY_N );

Now this error appears:

Call to undefined function __() in /home1/public_html/blog/wp-includes/wp-db.php

What would be the proper method of querying a database outside of WordPress?

Highlander79 on "Bootstrap integration?"

$
0
0

So, I am rather new to coding, but I have been trying to find resources on how to incorporate Bootstrap with Wordpress. The most recent articles I could find on this topic were from 2013, and when I followed them, I would get a lot of errors with the raw code showing through where a header or sidebar should be. I made some basic child themes to test with, so nothing actually affected my site.
Also, are there any ways to use different templates for different pages? For instance, I would like the home page to be a bold full screen image and also have a "blog" style page with a 4x4 grid of recent posts.
I know this is a lot, but any help would be greatly appreciated!


conquestcarbon on "Please help me"

$
0
0

Hi guys,

I have a Maya shop on my wordpress site http://www.conquestcarbon.co.uk and yesterday when anyone clicked on SHOP it would redirect you to "Index of /shop" page and another site selling christian_louboutins shoes. I contacted my host "vidahost" to find out what the problem might have been but they couldn't see anything, eventually I asked them to backdate my site to the last backup which seemed to have done the trick as the shop link was working as normal. However about 30 min ago the same thing has happened and I'm worried this might become a daily event. This shop is my business and I need it to work perfectly otherwise I will lose sales and income. Please can someone help me? Ive googled it and some have said it could be a Pharma attack??

I am not the most computer literate of people.

Kind regards

XoXoWP on "WP_List_Table -> get_bulk_actions -> Second Dropdown-Menu"

$
0
0

Hello, although I have searched quite a bit, have not found anything yet to my little problem. First of all: I read a few comments in a separate overview page, the table with the information I created this using "WP_List_Table", and I use "get_bulk_actions" to place a dropdown-menubox for delete, edit and so on.

Now I would like next to this dropdown box to add, however, another box to filter comments e.g. from "2012", "2013", "2014" and so on. Question: How can I add a second drop-down box of the "WP_List_Table" anyone here?

Patrick

handsofblue on "link post title to external site"

$
0
0

How can I link the title of a post to an external site while keeping the publishing date linked to the internal post like normal?

I've tried a few options but haven't been able to get exactly what I need:

The Page Links To plugin creates the external link for me, but then both the title and post date link to the external site.

The code shown here (http://wordpress.stackexchange.com/questions/64285/change-post-permalink-to-external-url-from-custom-field) seems to let me add an external link, but I can't figure out how to get that linked up to the post title.

(I'm not sure it matters, but just in case, I'm starting with WP's Twenty Fourteen theme. I don't mind messing with code at all, but my programming knowledge is rudimentary at best and I haven't been able to wrap my head around what exactly is going on and what I need to do to get this done.)

jim2k on "Show related posts by category"

$
0
0

Is there a simple, plugin-free way of showing a number of related posts from the same category on the single.php page (without showing the current post as part of the list, of course)? Perhaps using wp_query?

I've tried a bunch of things and the tutorials out there are all several years old and don't really work.

Thanks in advance!

Novtel on "2 Logins 1 Wordpress Site"

$
0
0

Good Morning All

I have been struggling with something that seems simple enough but can't figure it out.I have a wp-site that is split-up in 2 sections.1 is for Free Users and 2 is for Customers.

Using the login for the free users is nothing but the login for the Customers must be different because they will Register/login with a access code/voucher number that needs to be verified against the code/voucher number that's in the db already and must be automatically assigned with level 2 with a redirect to the customer side of the website.

I do have s2member free but it needs paypal pro to give me what i want(sort of).
I don't want to use paypal since I have my own payment method setup.

Is there a way to have 2 different login forms for one wp-site?

I don't know if it is possible but any help will be appreciated.

Thanks in advance

iminera on "Adding Sub Categories to Home Page"

$
0
0

Hi all,

I feel like such a noob when asking things like this because I am sure the answer is out there but I am not searching it the correct way.

Is there a way to add the sub categories I have on my menu to my homepage?

Only thing that shows now is "Featured Product".

Instead of it only showing "Featured Products" or even remove it, I, for example, would like to add the sub category of "Baseball Breaks" and its products if available and pretty much do it only for the sub categories in the "Group Breaks" category.

Any help with this is greatly appreciated.

http://minerasportscards.com/

I forgot to add that I am using woocommerce and Mystile theme.

Thanks!

Rahul Ramesh on "Adding Post Preview as Tinymce button"

$
0
0

Hi,
I searched every nook and corner of internet but I could not find a solution to add the "post preview" as a button in tinymce, along with other tinymce buttons like full screen and all. I want to do this so as to allow writers using "front end publishing system" in my site to preview their post before submitting.

So can this be done, through some hacks. I would love hear some solutions. Thanks in advance.


lyndonr on "Media Library View Defaults to "Uploaded to this post" Function"

joydipdas on "In my wordpress hosting I found someone logged in from my hosting providerd"

$
0
0

In my hosting account I have found some irregular activities. I have added Audit Log Viewer. Where it indicates two entries from my hosting provider IP has logged in and in Username it is mentioned as 'Unknown System'

My question, is it a system logged in or any individual logged in, which is not clear to me.

MatthijsdeGraaf on "Get available taxonomies from taxonomy"

$
0
0

Hi there,

I am running into an issue with selecting taxonomies;

Basically I want to have a list of available options upon a selection of either;

taxonomy 1; color
taxonomy 2; size

Upon selecting a color I want to show the user a list with the available sizes with that color.

Right now I select all posts with that color, and create a list with all sizes available. Though I am sure there is a better and faster way.

I can not seem to figure out a faster way of getting the info / the correct syntax.

Hope anyone can help me!

Thanks,
Matt

jchunick on "Custom post, custom taxonomy, missing relationship"

$
0
0

The Preamble:
I'm building a website for our hospital. On it we have a left side area on which is going to be populated what we are naming a 'Call to Action'. This 'Call to Action' is a custom post I have created. I have also created a custom taxonomy which will allow me to set a 'Call to Action' as being one of a list of categories such as 'Volunteer', 'Foundation', 'Did You Know', etc. Setting the category for a Call to Action does two things:

  1. Allow for certain pages with aligned messages to display the appropriate 'Call to Action'. For instance, pages about Volunteering would show Volunteer 'Calls to Action'.
  2. It will help style the Call to Action container/content appropriately.

It should also be noted that I have added a custom meta field to the Pages editor. This meta field pulls the 'calltoaction' taxonomy list and displays it as a group of checkbox options. This will allow the person editing the page to select which 'Calls to Action' are allowed to be shown on the given page.

What I would like to happen:

  1. When I create a new page I select which 'Calls to Action' are allowed to show on that page
  2. When someone goes to that page, code that's in the custom template of the page will:
    • get the allowed calls to action for the page
    • use WP_Query() to get a random 'Call to Action'
    • pass parameters to the function to limit the collection of records to the allowed 'calls to action'.

What is actually happening:
Up to this point, all my code and customizations work correctly. I am able to get a single, random 'Call to Action' to show. However, when I try to pass the array of allowed 'Calls to Actin' to the query it's not working.

Here's the code that works:

$args=array('post_type'=>'calltoaction', 'orderby'=>'rand', 'posts_per_page'=>'1');
$calltoaction = new WP_Query($args);

Here's the code I would like to get working:

$supported_cta = get_post_meta(get_the_ID(), 'supported_cta', true);
$where = array(
               'key' => 'cta_category',
               'value' => $supported_cta,
               'compare' => 'IN'
              );
$args=array('post_type'=>'calltoaction', 'orderby'=>'rand', 'posts_per_page'=>'1', 'meta_query'=>$where);
$calltoaction = new WP_Query($args);

Please let me know if you need more information or if screenshots of the custom post and taxonomy would help.

philippze on "get_adjacent_post_link excluded_terms ignored"

$
0
0

I call the function get_adjacent_post_link using the argument $excluded_terms. But this argument is ignored.

This is how I call the function.

get_adjacent_post_link(
    '%link',
    '<span class="forward"></span>',
    false,
    array(83, 88, 89, 182),
    true
);

By clicking the resulting link I can reach a post that is in the category 'Blog Eintrag (de)' which has this admin URL

/wp-admin/edit-tags.php?action=edit&taxonomy=category&tag_ID=83&post_type=post

I think that a post with this category should be excluded by the argument array(83, 88, 89, 182). Why is it not?

Viewing all 8245 articles
Browse latest View live




Latest Images