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

Avi Jit (skyhitblog) on "Code a tweet plugin and add follow option after tweeting."

$
0
0

Hi! I'm Avi.

I want to code the tweet button and want to add a follow option so that users can see a follow option after tweeting.

How can I do that?

Can anyone help?

I blog at skyhitblog.com and I want to implement the code there.

Please help me. thanks.


Antonio Correia on "create shortcode with data get dynamic"

$
0
0

Hi. If someone could help me, I thanks.

I have follow code;

$termo= "[product_page id='".get_product()->the_ID."']";
echo do_shortcode($termo);

the goal is to transform in a string code like this

[product_page id='231']

but what I get is:
231 [product_page id='']

Appreciate any help.
Thanks

csimpson on "Help using PHP Request for posting Form to Iframe"

$
0
0

Hi there, firstly any help is much appreciated. In very new to php but love wordpress!

I have searched the web everywhere for a simple solution to my issue but struggled to find a working answer.

In short, i have a form on homepage that allows entry of arrival date, departure date and number of guests. i need the form to post these parameters to an booking system provided by a third party BUT hosted on my website via an iframe - but another page, not the homepage where the form is - MUST EMPHASIZE THAT).

Anyway, i'm almost there! but I am struggling to work out the PHP to display a string of php request functions.

Firstly, my current implementation is showing this code on the page source code (NOTE: iframe delibrately spelt wrong to embed here)

<iBrame name="testframe" src="https://externalurl?siteId=KAYSCLAY&request_locale=en&chainAction=newAvailabilitySearch&29/11/201330/11/201312"></ibrame>

The url aspect of the iframe needs to be as follows:

https://externalurl?siteId=KAYSCLAY&request_locale=en&chainAction=newAvailabilitySearch&arrival=09%2F07%2F2013&departure=10%2F07%2F2013&numberOfPersons=1&numberOfChildren=0

So I have two problems. I am only showing two dates combined together in my iframe src string, these need to be seperated, and I am also missing two paramters for some uknown reason - number of people parameters.

Below is my code hardcoded on the iframe php page (html/php) and also my form. Any thoughts, help is much appreciated.

<ibrame name="testframe" src="https://externalurl?siteId=KAYSCLAY&request_locale=en&chainAction=newAvailabilitySearch<?php echo ''.$_REQUEST['arrival'].$_REQUEST['departure'].$_REQUEST['numberOfPersons'].$_REQUEST['numberOfChildren']?>"></ibrame>

<form action="/gatehouse-hotel/book-online/" method="get" name="pageform" onsubmit="return validate(this);" target="testframe">

	<div class="FormField Arrival">
		<label for="arrival">Arrival Date</label> <input id="arrival" name="arrival" type="text" /></div>
	<div class="FormField Departure">
		<label for="departure">Departure Date</label> <input id="departure" name="departure" type="text" /></div>
	<div class="FormField NumberOfPersons">
		<label for="numberOfPersons">Adults</label> <select id="numberOfPersons" name="numberOfPersons"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select></div>
	<div class="FormField NumberOfChildren">
		<label for="numberOfChildren">Children</label> <select id="numberOfChildren" name="numberOfChildren"><option value="0">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option></select></div>

<div class="FormField Submit">
		<input type="submit" value="Book now" /></div>
          </form>

    <script language="JavaScript">
    function validate(theform) {
    if (theform.domain.value == "") { alert("No domain entered"); return false; }
    return true;
    }
    </script>

PGrizz on "Adding a custom field in addition to Post Name to Permalinks?"

$
0
0

By default WordPress takes the page title you enter in the editor and makes it into a permalink. This title is usually also the h1 of the post.

If I keep the default title in the editor as my h1, but then add another h2 that's added by an Advanced Custom Field, how would I be able to combine the custom h2 field into my page's permalink to help my SEO?

For Example: My post's title would be "WordPress Title" and my custom h2 field added to the post would be "Example for Forum" so the url would end up being "site.com/wordpress-title-example-for-forum"

Doesn't seem like it's as easy as just appending the custom field on to the end of /%postname%/ in the Custom Structure of the Permalink settings.

Bazan on "custom nav_menu_item function"

$
0
0

Hello,

I have a CPT with a custom field called: special - yes/no value.

I want to do a custom nav menu item, that i can add item with text:
"Special product", which dynamically add url by find the only one post have a custom field special value on "Yes".

So if i change a custom field in products, i want that link in menu change, with no changes in admin's menu confugration.

Is it possible to define my own item like "SPECIAL PRODUCT" and set this link a dynamic link produced in some function?

I hope I explained it enough :P

I just want to change item link without change it in menu configuration, but by changing CPT custom value :)

cfetr on "edit-tag.php Sortable Column not sorting correctly"

$
0
0

Greetings everyone!

I have used the article over at scribu to add and make a column sortable for a taxonomy. The field is an int in the database and is sorted using meta_value_num ( also tried 'meta_value meta_value_num' and reversed). The problem arises when trying to sort the list on the column. My custom column is always sorted alphabetically by title even though I have chosen my column to sort on. Thanks for any help!

function term_order_column_orderby( $vars ) {
    if ( isset( $vars['orderby'] ) && 'term_order' == $vars['orderby'] ) {
        $vars = array_merge( $vars, array(
            'meta_key' => 'term_order',
            'orderby' => 'meta_value_num'
        ) );
    }

    return $vars;
	}
add_filter( 'request', 'term_order_column_orderby' );

ijwoods on "Token Acceptance"

$
0
0

My brain is fried and appreciate any help. Can this be done? I have a website (not Wordpress) in which I want participants to launch over to another website built in WordPress (also mine). I'd like to issue a authorization token from the non-WordPress website and then receive that at the Wordpress website when they arrive. Depending on the information contained in the authorization token they would be admitted and brought to a specific category landing page as per the token information. When they are finished at the Wordpress site they can then launch back to the non-Wordpress site being issued a token that would let them back in to their specific page.

Is this doable? Are tokens the best way? Any ideas as to how I might go about this or some good resources to check out?
thanks for any help.

elshan75 on "another css for featured products"

$
0
0

i want use the another css for featured products on woocommerce,What I do?


salgueirone on "Filter: Hide COD when Specific shipping is selected"

$
0
0

Hi,

i was trying to set a filter that would wide the cash-on-delivery payment when the costumer selects a specific shipping zone.(for out-of-town deliveries).
I'm using the Table Rates Plug-in

I was looking at this code (https://github.com/woothemes/woocommerce/issues/1499) at the answer by maxrice, but i can't adapt it to suite my needs,

My zone_id to exclude cod payment is table_rate-3

Thanks in advance

gilgimech on "Using conditional checks in the functions.php file"

$
0
0

You can't use the conditional checks in the functions.php file, because the functions.php file loads before the page loads, so the conditional functions have nothing to check against.

Like

function load_js() {
    if(is_home()){
        wp_register_script('main.min.js', THEME_URL . 'js/main.min.js', false, '1.0', true);
        wp_enqueue_script('main.min.js');
    }
}
add_action('init', 'load_js');

Just won't work. Correct?

I don't remember where I stumbled across this, but I discovered a work around.

if you add

<?php do_action('init'); ?>

after wp_head() the conditional checks in the functions.php work.

I don't now why this works, but it does.

Does anyone have any idea why this does work>

DFL on "Add Inline Style in Shortcode"

$
0
0

Hi Everybody. I have a problem. My shortcodes available custom colors etc. I need create inline css lines after my 'main' handler.

functions.php

function push_dfl_site_style() {
	wp_enqueue_style('main', get_stylesheet_uri());
}
add_action('get_header', 'push_dfl_site_style');

a example shortcode

function push_dfl_columns($atts, $content = null, $tag) {
	extract(shortcode_atts(array(
    	'class' => ''
  	), $atts ));

	global $wp_styles;
   	$wp_styles->add_inline_style('main', 'body {background-color: "red"}');
   	$wp_styles->enqueue(array('main'));

         bla bla.....
}

This not working

I try another lines

a example shortcode

function push_dfl_columns($atts, $content = null, $tag) {
	extract(shortcode_atts(array(
    	'class' => ''
  	), $atts ));

	function my_styles_method() {
        $custom_css = "
                body{
                        background-color: 'red';
                }";
        wp_add_inline_style( 'main', $custom_css );
	}
	add_action( 'wp_enqueue_scripts', 'my_styles_method' );

         bla bla.....
}

I get this error.
Fatal error: Cannot redeclare my_styles_method() (previously declared in.....

I need custom inline styles after my 'main' handler or in head tag.

Thanks for reading my problem. I hope you give me a advice :)

shrikanth on "Data Insertion"

$
0
0

I have created a plugin that inserts,fetches and updates records into mysql database, its working fine on local machine, but insert and update queries are not working on server, only select query is working, I can fetch the data but cannot insert and update record.
I have checked with the database grant privileges but still it is not working .

qdungeng on "How to get choice select name ACF"

$
0
0

Dear fiend
I have Select Customs Fields 'field_name', with more select :
name_1 : Name 1
name_2 : Name 2

How to get label "Name 1" or "Name 2" from choice select name1 or name2

thanks
.

rahul0010 on "need help for theme widget"

$
0
0

Hello Wordpress theme developers. I have to need help for create subscriber widget

How can I do that please help me I am no expert in Wordpress coding so I am confused. Here is my code it is not complete coding

class my_subscribe_widget extends WP_Widget {

	function my_subscribe_widget() {
	$widget_ops = array('classname' => 'widget_subscribe', 'description' => 'Add an RSS link' );
        $this->WP_Widget('my_subscribe_widget', 'RSS subscriber', $widget_ops);
	}

	function widget($args, $instance) {
		echo 'test';
	}

	function update($new_instance, $old_instance) {
		echo 'test';
	}

	function form($instance) {
		echo 'test';
	}
}

register_widget('my_subscribe_widget');

mohamedsamy on "Hide other users posts in admin panel"

$
0
0

i want to hide other users posts in admin panel for wp version 3.7.1

just any author can see own posts

help me please :)


jaja.px on "download link for audio"

$
0
0

hi
I'm using wordpress 3.6.1
wordpress can display a player automatically when I'm apload an audio file in a post but i want display duration and download link automatically bellow the player. powerpress plugin have these feature but i won't use plugin. how is this possible?

VOST on "Repeatable fields with dropdown lists of taxonomies' terms"

$
0
0

Hello,

I am trying to put in place repeatable fields with drop-down lists containing terms from custom taxonomies. It is displayed beneath the editor field in one of my custom post type.

Here is what I cannot achieve:

  • simply return the html for the drop-down lists (works fine when I try with inputs for example)
  • attribute values to dynamic options

In the end I got the 'Add a screening' (equal to "Add new field") button but when I click on it nothing happens; none of the fields appear.

My code is in the function.php file. This is the first part of the code with the drop-down lists which seems to cause me trouble - it was obtained more from tweaks of numerous copy and paste than from my little knowledge of php:

function print_screening_field($cnt, $p = null) {
if ($p === null) {
    $a = $b = '';
} else {
	    $a = $p['screeningName'];
	    $b = $p['screeningCountry'];

	    $festivalterms = get_terms('festival', 'hide_empty=0');
	    $countryterms = get_terms('country', 'hide_empty=0');

	        $html = '';
	        $html .= '<li>';

		$html .= '<label>Screening: </label>';
		$html .= '<select>';
		foreach ($festivalterms as $term) {
			$html .= '<option>';
			$html .= $term->name;
			$html .= '</option>';
		}
		$html .= '</select>';

		$html .= '<label>Country: </label>';
		$html .= '<select>';
		foreach ($countryterms as $term) {
			$html .= '<option>';
			$html .= $term->name;
			$html .= '</option>';
		}
		$html .= '</select>';
    	$html .= '<button class="remove">Remove</button>';
    	$html .= '</li>';
	}
	return $html;
}

This is the second part of the code; the meta box part with jQuery:

function screening_details_meta_box(){
	global $post;
	$custom = get_post_custom($post->ID);
  	$data = get_post_meta($post->ID,"screeningDetails",true);
?>

  	<h4>OTHER SCREENINGS</h4>
  	<?php
  	echo '<ul id="data_items">';
  	$d = 0;
    	if (count($data) > 0){
    	    foreach((array)$data as $p ){
    	        if ( isset($p['screeningName']) || isset($p['screeningCountry']) ){
    	            echo print_screening_field($d,$p);
    	            $d = $d +1;
    	        }
    	    }
	    }
	echo '</ul>';
   	?>
    <span id="here"></span>
    <button class="add"><?php echo __('Add a screening'); ?></button>
    <script>
    	var $ =jQuery.noConflict();
    	$(document).ready(function() {
    	var count = <?php echo $d; ?>;
    	$(".add").click(function() {
        	count = count + 1;
        		$('#data_items').append('<? echo implode('',explode("\n",print_screening_field('count'))); ?>'.replace(/count/g, count));
        			return false;
        		});
        		$(".remove").live('click', function() {
        			$(this).parent().remove();
        		});
        	});
    </script>
    <style>#data_items {list-style: none;}</style>
    <?php
}

As in case I don't find a solution, I can use the following piece of code with the screening_details_meta_box function (the one that contains the jQuery bit). But it means I am loosing the drop-down lists:

function print_screening_field($cnt, $p = null) {
if ($p === null){
    $a = $b = '';
} else {
    $a = $p['screeningName'];
    $b = $p['screeningCountry'];

    $festivalterms = get_terms('festival', 'hide_empty=0');
    $countryterms = get_terms('country', 'hide_empty=0');
}
return  <<<HTML
<li>
    <label>Screening:</label>
    <input type="text" name="screeningDetails[$cnt][screeningName]" value="$a"/>

    <label>Country:</label>
    <input type="text" name="screeningDetails[$cnt][screeningCountry]" value="$b"/>

    <button class="remove">Remove</button>
</li>
HTML
;
}

I would like to avoid any plugins. If you could simply mention the technical and exact terms describing what I am trying to do, it would be helping me in my research already.

Thank you

McGuive7 on "How to get URL of admin menu item?"

$
0
0

Hi there,

Is there a simple way to get the URL of admin menu items? I've grabbed the gobal $menu and $submenu arrays which contain quite a bit of info about each menu item, but digging into menu_header.php, it appears that there's quite a bit of conditional logic going on behind the scenes to generate basic urls (e.g. /wp-admin/options-general.php?page=easy-custom-templates, or /wp-admin/admin.php?page=wpcf-import-export). Some of the logic, for example, looks like this:

if ( ! empty( $menu_hook ) || ( ( 'index.php' != $sub_item[2] ) && file_exists( WP_PLUGIN_DIR . "/$sub_file" ) && ! file_exists( ABSPATH . "/wp-admin/$sub_file" ) ) ) {
	// If admin.php is the current page or if the parent exists as a file in the plugins or admin dir
	if ( ( ! $admin_is_parent && file_exists( WP_PLUGIN_DIR . "/$menu_file" ) && ! is_dir( WP_PLUGIN_DIR . "/{$item[2]}" ) ) || file_exists( $menu_file ) )
		$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), $item[2] );
	else
		$sub_item_url = add_query_arg( array( 'page' => $sub_item[2] ), 'admin.php' );

	$sub_item_url = esc_url( $sub_item_url );
	echo "<li$class><a href='$sub_item_url'$class>$title</a></li>";
} else {
	echo "<li$class><a href='{$sub_item[2]}'$class>$title</a></li>";
}

Does anyone know of a simple, reliable way to get admin menu item URLs for use in plugins? Thanks!

bsapaka on "how to display custom field/taxonomy in content via php templates"

$
0
0

I would like each post to display a list of its custom field data and its custom taxonomies in the content, but I am a bit lost with the php. What functions should I be looking at?

LebCit on "JavaScript loading but not working !"

$
0
0

Hello everyone,

After three days, war coding, to make a js file run, i have only this great place to ask, hoping that i'll find someone with good experience in js into WP to tell me what's wrong and how should i proceed to make it work.

First things first, i'm trying to implement a menu in a personal parent theme (i've tried to implement it for testing in underscores and in Twenty Thirteen).

1- After seting up the markup of my menu in a separate php file in the root of the theme folder (e.g. nav-top.php)

<ul id="gn-menu" class="gn-menu-main">
    <li class="gn-trigger">
        <a class="gn-icon gn-icon-menu"><span>Menu</span></a>
        <nav class="gn-menu-wrapper">
			<div class="gn-scroller">
				<ul class="gn-menu">
					<li class="gn-search-item">
						<input placeholder="Search" type="search" class="gn-search">
						<a class="gn-icon gn-icon-search"><span><?php get_search_form(); ?></span></a>
					</li>
					<li>
						<a class="gn-icon gn-icon-download">Downloads</a>
						<ul class="gn-submenu">
							<li><a class="gn-icon gn-icon-illustrator">Vector Illustrations</a></li>
							<li><a class="gn-icon gn-icon-photoshop">Photoshop files</a></li>
						</ul>
					</li>
				</ul>
			</div><!-- /gn-scroller -->
        </nav>
    </li>
    <li><a href="http://tympanus.net/codrops">Codrops</a></li>
    <li><!-- ... --></li>
    <!-- ... -->
</ul>

I left the markup like this for testing. Working fine under an html file !

2- I tried just to wp_enqueue_script the two necessary files for the menu and wp_enqueue_style in fuctions.php, without registering in a function !
Then i used <?php get_template_part('nav', 'top'); ?> at the top of the header.php before the title of the site.
The css worked just fine, i could see the menu bar, but the js files where not working since the sidebar panel of the menu was not opening.

3- I tried to register and enqueue the scripts and the style in a function in functions.php, but i had the same result as before, the css was here and the js files where not working.

4- I tried to integrate the navigation directly in header.php after
a- just enqueue the scripts and the style
b- register and enqueue the scripts and the style in a function
BUT, the result was always the same css working, js not working.

In the title i type "JavaScript loading..." i can tell because i saw the code source of my page and they where here like the style.

Oh, just for more info, when i enqueue or register/enqueue the js files, i've tried to put them in the footer than in the header (true, false), than i tried to call jquery in the array( array('jquery') ),
nothing seems to work !

Finally, why three days for an hour of testing ?
Hell, because i've tried a lot of menu and the result was the same for all of them : css working, js loading but not working !
And i made a lot lot lot of reading :)

So, the problem is in my experience with js in WP, it's my fault :)
I hope that someone will help me to finally pass this step and go further in js into WP.

Thanks a lot in advance for your help :)

Viewing all 8245 articles
Browse latest View live




Latest Images