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

bkmason on "enqueue can't find script file"

$
0
0

I would appreciate it if anyone can help me before I give up on wordpress altogether. I’ve been trying to do a so called “simple” enqueue ha! for at least 3 weeks. I’m trying to install a price table on my product page using my custom jQuery script. I’ve been to google, the forums, read the codex etc... Followed over 25 different enqueue and register script examples only to get Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'pricetable' not found or invalid function name in public_html/wp-includes/plugin.php on line 470. just a few examples I've tried are...

function theme_name_scripts() {
   wp_enqueue_style( 'style.css', get_stylesheet_uri() );
   wp_enqueue_script('pricetable',get_stylesheet_directory_uri()
. 'pricetable.js', array('jquery'), '1.0.0', false );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
function my_scripts_method() {
	wp_enqueue_script(
		'jquery',
		get_template_directory_uri() . 'pricetable.js',
		array('jquery')
	);
}
add_action('wp_enqueue_scripts', 'my_scripts_method');

add_action('woocommerce_single_product_summary','pricetable');`

function custom_scripts() {
	wp_register_script( 'jQuery', 'http://wp-content/themes/wootique-child/pricetable.js', array( 'jquery'), '1.0.0', false );
	wp_enqueue_script( 'jQuery' );
}
add_action( 'wp_enqueue_scripts', 'custom_scripts' );

My pricetable script starts...

jQuery(document).ready (function($) {
var x = document.createElement("TABLE");
x.setAttribute("id", "pricetable");
document.body.appendChild(x);

I’m using a wootique-child theme and have installed woocommerce, a function.php, header file, etc… in its child directory. I’ve tested the function file by writing a simple “hello world” function and placing “hello world” in different areas of the product page using action and filter hooks. I’ve also placed my no-conflict anonymous jQuery “pricetable” script in the child themes header which allows the table to be displayed and manipulated by the child style.css file on the product page. However the product page hooks that I’ve placed at the end of the script don’t work and it doesn’t matter if their commented out or not. This might be the reason the table is appended to one side of the product page and the table data is slightly off center. That problem could probably be fixed by tweaking the css file. The strange thing is that the table only appears on the product page, like it supposed to, without the aid of the product page hooks?

I would like to use my child function.php to call the “pricetable.js” file the correct way so that I can clean up my templates and use the add action and filter hooks to place the table in the proper area of the product page. Neither the literature nor examples indicate where any of the files they mention need to be placed. Therefore I’ve placed my “pricetable.js” file in several different areas to try and make it work. In the child theme I placed the pricetable.js file directly in its subdirectory using the wp-content /themes /wootique-child/ pricetable.js path. In both the parent and child theme I also placed the “pricetable” file in wp-content/themes /wootique(child) /includes/js/ pricetable.js. I’ve tried enqueue in both the child and parent theme. Whatever file path I use, method of register or enqueue, wordpress can’t locate the "pricetable.js" file.
It also would be nice to know the proper syntax so I can use the hooks as a variable in my script to retrieve the products base price to use in the table.
Thank you I appreciate your help


Daniel McClure on "Problem Trying to Sum SQL decimals with specific ID"

$
0
0

I am trying to add up all the values within a decimal column where the ID is equal to a queried ID. I have tried many solutions and nothing seems to work. The current solution seems to provide an answer however it is the wrong one.

/* Sum payments made to invoice number */
$payments_table = $wpdb->prefix . "_payments";
$invoice_id = '999999999';

$result = $wpdb->query('SELECT sum(value) FROM '.$payments_table.' WHERE invoice_id = '.$invoice_id.'');
echo $result;

In the database there are currently two payments of '0.001' for invoice '999999999' so I would expect the sum to be '0.002' however the code returns '1'

Engr.MTH on "Building Form Builder Page"

$
0
0

Hi,

I built a plugin that allows users to submit and edit posts from the frontend.

Now I want to make it multiform I built form custom post type and make some meta boxes.

Is there any framework or tutorials can help me build form builder page like the one that we found in Gravity Forms, or Visual Form Builder, or WP user frontend pro?

Or I should start from scratch?

cipriano200 on "how to convert this code?"

$
0
0

The code below pulls child categories of a parent, works perfectly.

Still i want to use this type of solution for TAXONOMIES, any ideas how to convert this?

<?php
global $ancestor;
$childcats = get_categories('child_of=' . $cat . '&hide_empty=1');
foreach ($childcats as $childcat) {
  if (cat_is_ancestor_of($ancestor, $childcat->cat_ID) == false){
    echo '<a class="trick product-search-item" href="'.get_category_link($childcat->cat_ID).'">';

	echo '<img src=';
	echo z_taxonomy_image_url($childcat->term_id);
	echo '>';
	echo '<div class="icon"></div>';
	echo '<span>';
	echo $childcat->cat_name . '</span>';
    echo '</a>';
    $ancestor = $childcat->cat_ID;
  }
}
?>

truheart on "Get custom taxonomy terms to be displayed in relative categories?"

$
0
0

Hi everybody,

Sorry it was really hard to think of a good topic title that would describe what I am going for. So here is the story...

I have set up a taxonomy filter for my client that displays results on the search template. Here is the main part of the code that relates to this question:

<!-- Search Results Container -->
<div id="search-container">
	<?php /* Start the Loop */ ?>
	<?php if( have_posts() ) : while ( have_posts() ) : the_post(); ?>
		<?php // Retrieve Custom Taxonomy Values for Each Attorney.  I.e. their location, position, etc.
			//$location = wp_get_object_terms( $post->ID, 'locations');
			//$bar_admissions = wp_get_object_terms( $post->ID, 'bar-admissions');   <-- UNCOMMENT THESE IF YOU WOULD LIKE TO INTEGRATE THEM INTO THE SEARCH RESULTS.  YOU WILL ALSO HAVE TO EDIT THE SINGLE ATTORNEY SECTION AS SEEN BELOW
			//$languages = wp_get_object_terms( $post->ID, 'languages');
			//$practice_areas = wp_get_object_terms( $post->ID, 'practice-areas');
			//$schools = wp_get_object_terms( $post->ID, 'schools');
			$link = get_permalink();
			$position = wp_get_object_terms( $post->ID, 'positions');
			$position = $position[0]->name;
			$phone = get_field( 'phone_number' );
			$email = get_field( 'email' );
			$vcard = get_field( 'vcard' );
		?>

		<!-- Single Attorney Entry -->
		<div id="attorney-entry">
			<span><a href="<?php echo $link; ?>"><strong><?php the_title(); ?></strong></a></span>
			<span>P: <?php echo $phone; ?></span>
			<span>E: <a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></span>
			<span><a href="<?php echo $vcard; ?>" download><img src="<?php echo site_url( '/wp-content/themes/rodenolaw/images/vcard_download.png' ); ?>" width="48" height="48" alt="vCard"></a><span>
			<span class="position"><?php echo $position; ?></span>
		</div>
		<!-- /end single attorney entry -->

	<?php endwhile; else: ?>
	<!-- Message if no attorneys are found -->
	<p>Sorry, no attorneys matched your criteria. Please go back to our <a href="our-attorneys">attorney directory</a> and try again.</p>
	<?php endif; ?>
</div>
<!-- /end search results container -->

So I have this configured to display the results in alphabetical order according to custom taxonomy called last-name. Everything is working fine up to this point.

So what my client would like is for the the results page to look something like this: http://www.brunini.com/attorneys-search.html. As you can see, the results are organized and displayed in seperate categories according to the first letter of their last name.

What I already have set up is a custom taxonomy called last-name-latter. What I am looking to do is have the search results page check to see which terms for last-name-letter are showing up from the queried posts (the terms would be A, B, C etc.), then display alphabetical headings for the terms used as well as list the attorneys with the same terms underneath their corresponding headings. It would be easier to understand if you just visit the example site I mentioned.

I am thinking I will have to set up individual divs for every single letter, then use a conditional to display them only if their term shows up in one or more of the queried post. I will have to think through this more, but just seeing if any of you can come up with a clean solution to this.

Thanks ahead of time.

hilman050 on "Remove plugin-items from dashboard-menu"

m.lavarde on "only label of the shortcode display"

$
0
0

Hi all,

I am trying to modify plugin Simple Yearly Archive. This plug in display an archive by year and allow to show several details of the posts (title, category, excerpt...)

I'm currently trying to modify php in order not to show excerpt but content.

$excerpt = ''; if(get_option('sya_excerpt')==TRUE) { if ( $maxzeichen != '0' ) { if ( !empty($post->post_content) ) { $excerpt = substr($post->post_content, 0, strrpos(substr($post->post_content, 0, $maxzeichen), ' ')) . '...'; } } else { $excerpt = apply_filters('the_content', $post->post_content); } $listitems .= '<br /><div style="padding-left:'.$indent.'px" class="robots-nocontent"><cite>' . strip_tags($excerpt) . '</cite></div>'; }

I have already replace $post->post_excerpt by $post->post_content and add $excerpt = apply_filters('the_content', $post->post_content);.

Currently the page is looking like this http://graye-sur-mer.org/wordpress/compte-rendu-des-seances-du-conseil/ and I would like instead of Download to have the button like in http://graye-sur-mer.org/wordpress/conseil-municipal-du-18-avril-2014/.

I have already tried several things:
1- replace $excerpt = apply_filters('the_content', $post->post_content);by $excerpt = get_content(). In this case the download button is display but in a new div on top of the year.

2- replace $listitems .= '<br /><div style="padding-left:'.$indent.'px" class="robots-nocontent"><cite>' . strip_tags($excerpt) . '</cite></div>'; by $listitems .= '<br /><div style="padding-left:'.$indent.'px" class="robots-nocontent"> echo $excerpt</div>'; then the page crashes.

If someone has the clue, please let me know.

m.lavarde on "if in the attribut of a shortcode"

$
0
0

Hi all,

I'm trying to customize shortcode Event List Shortcode provided in the plugin Event Organizer in order to have in my sidebar a list of event from a specified category, which is the category of the main page.

So far I wrote the following

<?php
global $wp_query;
$page_id = $wp_query->post->ID;
$category = get_post_meta( $page_id, 'category', true );
?>

<?php
echo do_shortcode('[eo_events event_category="' . $category . '" showpastevents=false]
<div style="background-color: #ececec; width: 160px; padding: 10px; margin: 15px; opacity: 0.91; font-size: 14px; line-height: 20px;">
    <div class="eo-date-container">
		<span class="eo-date-month" style="background-color: #1e8cbe; float: right; text-align: center; width: 50px; line-height: 1.3; margin: 0px; display: block; font-size: 14px; font-variant: small-caps; color: white; letter-spacing: 3.2px;">%start{M}%</span><br/>
		<span class="eo-date-day" style="background: #27b6f7; float: right; text-align: center; width: 50px; line-height: 1.3; margin: 0px; display: block; font-size: 32px;">%start{j}%</span>
	</div>
<div class="eo-event-meta-container">
		<span class="eo-event-title" style="color: #f99734; font-size: 20px; line-height: 30px; font-weight: bold;"><a href="%event_url%">%event_title%</a></span><br/>
		<span class="eo-event-meta" style="font-size: 12px;"> @ <em><a href="%event_venue_url%">%event_venue%</a></em> </span><br/>
			<span class="eo-event-meta" style="font-size: 12px;">de %start{H}%h%start{i}% à %end{H}%h%end{i}% </span>
</div>
<div style="clear:both"></div>

	<div style="align: center;">
		%event_thumbnail%
	</div>
		%event_content%
<div style="font-size: 10px; width: 150px; line-height: 12px; background-color: #F5DA81; margin: 3px; padding: 3px;">
Organisateur et contact : %event_custom_field{organisateur_contact}%
</div>
</div>
[/eo_events]'); ?>

I would like to add some conditions in case %event_content% or %event_venue% or %event_custom_field{organisateur_contact}% are empty.

I tried `if(%event_custom_field{organisateur_contact}%) {
Organisateur et contact : %event_custom_field{organisateur_contact}%
}but it did not work it returns a text if( value of%event_custom_field{organisateur_contact}%`) {
Organisateur et contact : value of %event_custom_field{organisateur_contact}%
}

Thanks in advance for your help


ashimo5000 on "Custom taxonomy - removing archive pages entirely?"

$
0
0

I have created a new custom taxonomy for users to select pre-existing messages to include at the bottom of a post. I do not want there to be any archives for these taxonomies.

How would I go about removing/deleting the archive url instances? Is my only option to use htaccess?

lopxen on "Empty wpdb->get_resuts die de execution"

$
0
0

Hi,

I am running a "SELECT" sentence via wpdb->get_results($sql) or die (mysql_error()).

When the sentece produces results, no problem, but if there result is "empty", the "die()" stops de execution, but it the mysql_error() shows nothing. Furthermore, mysql_errno() is 0.

The question is, if there is no sql error, why die() stops the execution?

I been searching for hours in the internete, but nothing. I am getting completely crazy!!!

Thanks!!

miowebdesigns on "Calling outside programs with $_GET"

$
0
0

Here is the thing. I have created a site and on it we need to call a program that downloads vcards, one for each employee. That means I need to pass the id for that employee. I am trying $_GET. I have tried a straight call passing the parm. I tried creating a page and passing the parm thru the page. Here is a link: http://hsm.bothwip2013.com/attorneys/. I have never attempted this before. Any ideas?
Two samples of code attempted:

<a href=\"http://hsm.bothwip2013.com/atty-vcard/?id=$attorney_id\" class=\"atty-vcard\" title=\"Download Vcard\">

<a href=\""; ?>
<?php bloginfo('template_url'); ?>
<? echo "child/attorney-vcard.php?id=$attorney_id\" class=\"atty-vcard\" title=\"Download Vcard\">

Thanks

rioforce on "What is "If Modified Since"?"

$
0
0

Hi,

I have heard about something called "If Modified Since" and it is some type of HTTP header that it is supposed to speed up your site. I have searched a lot, and have contacted Bluehost (my host) and I haven't figured it out. Could somebody tell me what "If Modified Since" is, and how to enable it? I have checked on FeedTheBot and Microsoft, and nobody says I have it enabled.

My web domain is http://whitfieldpineseedlings.com

Thanks!

mohammed007 on "Hide year of recent post widget"

Bensji on "Custom post type"

$
0
0

So I've got my portfolio page (with images defined by html (by css is possible if needed)). And now I 'add' portfolio information pages by just making a new page, and then putting the link of that page in the href of the according image on my portfolio home page.

Is there a way I can (by using CPT):
- Add an image on the portfolio page
- Add an new portfolio information page (with an custom template (I am now just manually selecting the template when I make a portfolio information page).
- Automatically insert the url of the portfolio information page on that image (on the portfolio page).

Or is this not possible?

(for better understanding I have already obtained this by doing it manually on my site (you can click on the images and then be taken to the portfolio information page), I would like to do this by using CPT ...

Thank you!

John Harper on "custom url with custom post"

$
0
0

I want to change my custom post URL. i want to remove "item" from URL.

with the below code my URL is.

Original URL : http://mywebsite/wp/item/america/mayer/

Want to Change as http://mywebsite/wp/america/mayer/

Without ht access.

function aitDirItemPostType() {

        register_post_type( 'ait-dir-item',
            array(
                'labels' => array(
                    'name'          => 'Items',
                    'singular_name' => 'Item',
                    'add_new'       => 'Add new',
                    'add_new_item'  => 'Add new item',
                    'edit_item'     => 'Edit item',
                    'new_item'      => 'New item',
                    'not_found'     => 'No items found',
                    'not_found_in_trash' => 'No items found in Trash',
                    'menu_name'     => 'Items',
                ),
                'description' => 'Manipulating with items',
                'public' => true,
                'show_in_nav_menus' => true,
                'supports' => array(
                    'title',
                    'thumbnail',
                    'author',
                    'editor',
                    'excerpt',
                    'comments',
                ),
                'show_ui' => true,
                'show_in_menu' => true,
                'menu_icon' => AIT_FRAMEWORK_URL . '/CustomTypes/dir-item/dir-item.png',
                'menu_position' => $GLOBALS['aitThemeCustomTypes']['dir-item'],
                'has_archive' => true,
                'query_var' => 'dir-item',
                'rewrite' => array('slug' => 'item'),
                'capability_type' => 'ait-dir-item',
                'map_meta_cap' => true
            )
        );
        aitDirItemTaxonomies();

        flush_rewrite_rules(false);
    }

add_action( 'init', 'aitDirItemPostType');

AvWijk on "Extra CSS class in last column (loading posts in loop)"

$
0
0

Probably a very easy question to solve:

I have a bootstrap framework with four columns, only thing is that the last column should have a class added 'column-last'. How do I do that?

Code is as follows

<?php if (have_posts()) : ?><?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("category_name=portfolio&paged=$paged&posts_per_page=4"); ?>
                             <?php while (have_posts()) : the_post(); ?>
								   <?php if (has_post_thumbnail( $post->ID ) ): ?>
                                         <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>

                                 <div class="percent-one-fourth box fadeIn"><div class="work-member"><a title="Roche Corporate Mobile Website"><img class="work-avatar tempfilter" src="<?php echo $image[0]; ?>" alt="<?php the_title() ?>" title="<?php the_title() ?>"/></a></div></div>
                                     <?php endif; ?>
                                     	<?php endwhile; else: ?>
                		<?php endif; ?>

AJ Troxell on "Translation function calls must NOT contain PHP variables"

$
0
0

I am newer to WP plugin development and extensive Theme development. I am using and altering a theme options sample from ThemeShaper. My problem is localization and the structure of the theme-options.php file.

I know that this is improper: esc_attr_e( $options[$input['Input']] );

But I know not how to restructure it so that it is proper, but figured it would be something like this: esc_attr_e( _n('%d', '%d', $options[$input["Input"]], 'white'), $options[$input["Input"]] ); yet all this does is fill my fields with a value of %d.

Can anyone lend me a hand on how to make this proper?

rajlaksh on "unable to access wpdb"

$
0
0

I'm using wp 3.9.1 on my windows PC

its able to access wp-load.php and able to run queries.

But i use that in website its unable to access database. and got these error.

Warning: mysql_real_escape_string(): Access denied for user ''@'localhost' (using password: NO) in /home/public_html/ajx.php on line 13

Warning: mysql_real_escape_string(): A link to the server could not be established in /home/public_html/ajx.php on line 13

turkel on "Global Comment modification for Multisite WP"

$
0
0

Hi,

What I need is to add one field before submit button in all over my wordpress network sites` comment forms. I have user comment_form function with its some filters and there are was no any luck.
Please advise how can I do this.

Regards,
Turkel.

HeavenCore on ""Show Toolbar when viewing site"& wp_insert_user()"

$
0
0

Hi there,

When creating a new user in code via wp_insert_user() - how does one specify false for the "Show Toolbar when viewing site" setting found under the default Wordpress Admin GUI?

My code thus far:

$userdata = array(
        'user_login'    =>  $Email,
        'user_pass'     =>  $Password,
        'user_email'    =>  $Email,
        'display_name'  =>  $FirstName . " " . $LastName,
        'nickname'      =>  $FirstName,
        'first_name'    =>  $FirstName,
        'last_name'     =>  $LastName,
        'description'   =>  'Created via custom Registration Page - ' . date("YmdHis")
    );

    //#### Create the WordPress user
    $user_id = wp_insert_user( $userdata ) ;

    //#### Check user was created OK, if not, return error, if so, return userID
    if( is_wp_error($user_id) ) {
        custom_ajax_exit("ERROR:" . $user_id->get_error_message());
    } else {
        custom_ajax_exit("OK:" . $user_id);
    }
Viewing all 8245 articles
Browse latest View live