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

pipspeak on "populate new admin column with meta value"

$
0
0

I'm a bit stumped with this... I have a new column (att_order) in the admin post list for a custom post type (attorneys) and I want to populate it with the values from a custom meta key (_att_meta_order). This is as far as I got:

add_action('manage_attorneys_posts_custom_column', 'manage_att_custom_columns', 10, 2);
function manage_att_custom_columns( $column, $post_id ) {
	global $post;
	switch( $column ) {
		case 'att_order' :
		$att_order = get_post_meta( $post_id, '_att_meta_order', true );
		break;
	}
}

And me being here means it doesn't work! The column remains empty. What is the correct way to grab a meta value for a column? Any help appreciated.


manzanofab on "Use URL URI to query a table in database instead of default wp behaviour"

$
0
0

I am just wondering how to achieve the following, i have a wp site, which will contain only 1 page (main page)
I design a plugin that creates a table in the database and the plugin allow me to introduce records into this table, one of the columns of the table is Name.
when someone goes in my site to
site.com/somethinghere
i want to search my custom table a record which has the name of "somethinghere"

and display all the other data that the record has.

instead of the default behaviour of wp, that tries to open a page or post and if it doesnt find it goes to error pagea

lookiz on "Change Default "Posts" Admin Icon"

$
0
0

I've been trying for the life of me to figure out how to change the default "thumbtack" icon of the "Posts" menu on the backend to something else. Unfortunately, when searching Google for this, all I get is how to do it with Custom Post Types—not the default/existing "post" post-type. I know with a Custom Post Type you use 'menu_icon' in your args when registering the Custom Post Type, but I can't figure out how to do it with 'post'.

meskunas on "If URL then get this"

$
0
0

I have a WordPress website that requires certain scripts to be run based on if category, or if page etc.. I need to be able to add to this, if exists in URL then...

Here is what I have now

'<?php
if (is_front_page()) { include("empty.php"); }
elseif (is_home()) { include("empty.php"); }
elseif (is_page( array('691', '850', '2072', '2064', '2077', '2052'))) { include("empty.php"); }
elseif (is_single( array('480', '36094', '26'))) { include("empty.php"); }
elseif (in_category( array('42', '26', 'marketplace', 'Obituaries', 'obituaries'))) { include("empty.php"); }
else { include("paywall.php"); }
?>'

I want to be able to add this, if URL contains (array('events', 'calendar', 'movies') then include empty.php

I am having problems finding code to do this. Perhaps add a function to functions.php and call it 'elseif(in_url(array....'

vincentloos on "wp-login.php shows source code"

$
0
0

Hello,
I was trying to change the logo on the login page but now my login page shows only the source code. Does any1 have to original wp-login.php file? This is the site

webtent on "Adding dynamic content to a plugin CPT"

$
0
0

Not getting any replies to past posts, please let me know if I'm not posting in the correct forum. I am a decent PHP programmer, but new to WordPress development. I did get my feet wet with one site we recently did and love the power of WP shortcodes, however, I am not able to place shortcodes in the pages of a CPT that I need dynamic content.

I need to add dynamic code to pages produced by a CPT created by a plugin. The code should only generate on the pages for this certain CPT. Depending on values of the CPT categories or custom fields, the code will either include a player in the page for playing an audio playlist or a form with one date field to post back to itself and download an audio file based on that date.

Could someone suggest the best approach for making this work?

Thanks, Robert

datainterlock on "add metabox to add new link"

$
0
0

How would you add a custom metabox to just the 'add new link' admin page when there is no 'link' post_type??? I've got the metabox added but I'm not sure how to specify just the links page.

hathbanger on "Custom quote plugin breaks on firefox, IE, and Safari - AJAX"

$
0
0

I'm developing a quote calculator that queries the db for the price of the option (set in an admin area) and then uses the user input from the widget to the calculate a quote for a prospective customer via AJAX.

I've been developing in chrome with no issues, but when I go to test it on different browsers, it breaks.

The form still shows up on all browsers which is cool, but when I calculate the quote on everything except for chrome, it just spits out 0.

I took a look at firebug and it says that it's successfully making the POST request to the server, but the response is broken.

Any help you guys could offer would be greatly appreciated!!!!!

Thanks in advanced,

Andrew


Avery1 on "ob_end_flush error"

$
0
0

When I tested my contact form I got this error, although it worked fine last time I tested it:

Warning: Cannot modify header information - headers already sent by (output started at /home/mysite/public_html/wp-content/plugins/seamless-schema/seamless-schema.php:126) in /home/mysite/public_html/wp-includes/pluggable.php on line 1196

Line 126 of seamless-schema.php is: >@ob_end_flush();

/**
* End output buffering during header
*/
function seamless_schema_buffer_end()
{
@ob_end_flush();
}
add_action('wp_head', 'seamless_schema_buffer_end');

Line 1196 of pluggable.php is:

header("Location: $location", true, $status);

How do I fix this? I think the problem may be the lack of a ob_get_content command (??) The plugin author does not seem to be available, so I'm asking here..

recordnj on "Share >140 Char Post with Twitter"

$
0
0

Is there a way to share a post, with greater than 140 characters, with Twitter? Has anyone out there used an API with Twitlonger or some other app? I have some wordy posts that my users could share, but don't want them cut off.

Thanks!

tayssir.ch on "How to Add Attend/Not Attending to Events Managment System?"

$
0
0

I am using Easy Content Type to create my own platform to organize my events.

I Created :
Post Type: Contact
Taxonomy1: Groups
Taxonomy2: Events
Metaboxes :
- Name
- Position
- Address

after adding my contact list,
and selecting which Contact are invited to Event

how can i add checkbox (or dropdown).. with this option:
Attend/Not Attending

please note that there are lot of event,
and each contact may be invited to many event

so the relation should be between
Post type - Taxonomies - Checkbox

Alain Kassabian on "How can a URL delete a post?"

$
0
0

I'm trying to wrap my head around how simply loading a URL can delete or modify comments or posts, which I presume are stored in the database. I've seen this ability referred to in several places:

https://codex.wordpress.org/Function_Reference/get_delete_post_link

class-wp-comments-list-table.php: $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );

The Wordpress codex page on Nonces states: "For an example of how an nonce is used, an admin screen might generate a URL like this that trashes post number 123. You can see that the URL contains a nonce at the end: "

If anyone has a quick answer and can spare me waiting for my own conclusion, I'd appreciate it.

nobita on "switch_theme hook not work when change the theme customizer"

$
0
0

Hi

When I changed the theme, I want to remove the value of the theme options,

when change with theme customizer, it seems not be used switch_theme hook.

In the customizer, a hook that works when change the theme?

Thank you.

mortrza1371 on "Insert and then update post_type by wp_update_post"

$
0
0

I wrote a function to insert content in the page and every date update automatic .

I used wp_update_post( $my_post ); to update page .

I want first insert content in top specific page and then update, but it isn't working.

it's only updating or inserting content..

function wp_emallmobnok(){
        $postdater =  parsidate('j / F / Y',$datetime='now',$lang='pre');
        $postdate = date('Y-m-d H:i:s');
        $ta = parsidate('j / F / Y',$datetime='now',$lang='pre');
        $postdate_gmt = date('Y-m-d H:i:s');
        $titles="price daily";
        $posts = array(

            'post_content'   => $oiobz1,
            'post_name'      => $titles,
            'post_title'     => $titles,
            'post_type'      => 'page',
            'post_status'    => 'publish',
            'post_author'    => '6',
            'ping_status'    => 'open',

            'post_date'  => $postdate_gmt,
            'post_category' => array(188),
            'tags_input'     => " price",
        );

        $post_id = wp_insert_post($posts);//// instert post
        add_post_meta( $post_id, ' wp_insert_post', 0, true );

        $post_up = wp_update_post($posts);///update post
        add_post_meta( $post_id, ' wp_update_post', 0, true );

}

srihariwp on "How do I fix W3C CSS Validation Errors"

$
0
0

Hi,

I found huge errors in w3c.org. How do i fix that errors any suggestion??

"Sorry, the at-rule @-webkit-keyframes is not implemented." error is one of them.

I'd appreciate it.


worldtravelgeek on "Insert widgetized area into loop, independent of theme"

$
0
0

Hi guys,

I thought this would be simple somehow but I guess it isn't. Let me start by saying that I am no coder but willing to learn a bit if necessary. I was looking for a way to inject one (or more) widgetized area(s) into the wordpress loop, for instance before the 1st or 3rd etc post.

Now I have found a few instructions for that but mostly it consists of registering a dynamic sidebar in functions.php and then hack index.php or category.php etc by looking for "endwhile" and inserting the dynamic sidebar before that.

However, this is very theme dependent. Whenever I switch themes I need to adapt and reinsert that code to fit with the new theme, some of them don't even seem to have that "endwhile" in index.php.

So I was thinking of implementing this as a plugin, independently of the theme used. I have found a way to register the dynamic sidebar by creating a plugin consisting of a site_functions.php and adding this:

register_sidebar(array('name'=> 'WidgetArea1',
    'id' => 'Widget1',
    'description' => esc_html__('Widgets appear before 1st post', ''),
    'before_widget' => '<section id="%1$s" class="WidgetArea1">',
    'after_widget' => '</section>',
    'before_title' => '',
    'after_title' => ''
));

So now I know I am supposed to add something like this to the loop:

<?php
if ($count==1) {
dynamic_sidebar(‘WidgetArea1’);
}
$count = $count + 1;
?>

How and where can I do this (or something else ?) with my plugin so that the widget area appears in every theme, no matter how it displays the blog posts and which layout it uses (standard, masonry, isotope, etc) and without hacking theme files every time I switch themes.

Ideally that would also be extendable to archive or category pages etc

I am actually amazed that there doesn't seem to be a plugin on the market that can do things like that already. There are thousands of plugins available for wordpress but obviously not for something apparently simple like that. I hope it is possible ?!?

Thanks a lot for your help guys!
Alex

PS: If this is really complicated and any of you talented developers out there would prefer to create a plugin that does things like that I would even pay a little. Probably others as well ... ;)

chriswindsor on "Change user role based on account spend woocommerce"

$
0
0

Hello. I have been working on an issue for a little while and can't seem to find the solution. I am attempting to develop a function that changes a customer's account type (ie from 'customer' to something else) once their account spend hits a certain amount.

Here is what I have tried so far. I very new to writing php and functions so I apologize upfront for the mess this may be. Any help would be appreciated.

/**
 * Get total spent by customer
 * @param  int $user_id
 * @return string
 */
function wc_get_customer_total_spent( $user_id ) {
if ( ! $spent = get_user_meta( $user_id, '_money_spent' < 50 ) ) {
global $wpdb;
 // Remove role
        $user->remove_role( 'customer' );

        // Add role
        $user->add_role( 'procon' );

$spent = $wpdb->get_var( "SELECT SUM(meta2.meta_value)
FROM $wpdb->posts as posts

LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
LEFT JOIN {$wpdb->postmeta} AS meta2 ON posts.ID = meta2.post_id

WHERE   meta.meta_key       = '_customer_user'
AND     meta.meta_value     = $user_id
AND     posts.post_type     IN ('" . implode( "','", wc_get_order_types( 'reports' ) ) . "')
AND     posts.post_status   IN ( 'wc-completed', 'wc-processing' )
AND     meta2.meta_key      = '_order_total'
"

        );

update_user_meta( $user_id, '_money_spent', $spent );
}

return $spent;
}

lunchgirl on "press this hack"

$
0
0

I am using P2 for my theme and making some child versions.
I would like to be able to use a press this hack from the front end to let users know they can drag their's to the toolbar so that my users don't have to go to the back end to fetch their's.

Any ideas?

tayssir.ch on "How to build event guest attendance with wordpress?"

$
0
0

I Created :
Post Type: Contact
Taxonomy1: Groups (Deans, Assistant Dean,...)
Taxonomy2: Events (Event Name 1, Event Name 2,,,,)
Metaboxes :
- Name
- Position
- Address

How i should add Attendance ? it is a taxonomy or what ?
please not there are lot of events,
and contacts may be invited to many events,
and i want to mark the attendance for each event.

Mikos91 on "Woocommerce, payment gateways for downloads"

$
0
0

I would like to restrict the payment gateways for downloadable products. Now a customer can order a downloadable product and pay by COD. Even if the payment isn't made, the customer can go to his account en download the product.

The option to let customers download direct after the checkout have to stay.

In short,
- Payment Gateways should be limited for downloadable products (only iDeal by Mollie and no COD, Cheque, Bacs).
- Direct download after the checkout page have to remain.

I found this code somewhere which restrict 'categories', i'm trying to shape it to my needs. But since i'm not an expert, i definitely need some help :)

function filter_gateways($gateways){

$payment_NAME = 'paypal'; // <--------------- change this
$category_ID = '20';  // <----------- and this

 global $woocommerce;

 foreach ($woocommerce->cart->cart_contents as $key => $values ) {
	// Get the terms, i.e. category list using the ID of the product
	$terms = get_the_terms( $values['product_id'], 'product_cat' );
	// Because a product can have multiple categories, we need to iterate through the list of the products category for a match
	foreach ($terms as $term) {
		// 20 is the ID of the category for which we want to remove the payment gateway
		if($term->term_id == $category_ID){
               unset($gateways[$payment_NAME]);
                   // If you want to remove another payment gateway, add it here i.e. unset($gateways['cod']);
					break;
          }
	    break;
	}

   }
	return $gateways;

}

add_filter('woocommerce_available_payment_gateways','filter_gateways');

If somebody could help it would be great!

Thanks anyway!

Viewing all 8245 articles
Browse latest View live




Latest Images