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

wdlyons on "Correct metgod to include wp-load.php"

0
0

Hi,

I submitted the plugon and received the following email back from Wordpress:

Including wp-config.php, wp-blog-header.php, wp-load.php, or pretty much any other WordPress core file that you have to call directly via an include is not a good idea and we cannot approve a plugin that does so unless it has a very good reason to load the file(s). It is prone to failure since not all WordPress installs have the exact same file structure.

Usually plugins will include wp-config.php or wp-load.php in order to gain access to core WordPress functions, but there are much better ways to do this.

It's best if you tie your processing functions (the ones that need but don't have access to core functions) into an action hook, such as "init" or "admin_init".

Please consult the Plugins API reference for more information: http://codex.wordpress.org/Plugin_API

If you're trying to use AJAX, please read this: http://codex.wordpress.org/AJAX_in_Plugins

When you've corrected your code, reply to this email with the updated code attached, or provide a link to the new code.

However, I do not use include and the only file I call is wp-load.php

The code I use to do this is:

$parse_uri = explode( 'wp-content', $_SERVER['SCRIPT_FILENAME'] );
require_once( $parse_uri[0] . 'wp-load.php' );

Can anyone point me in the right direction to what I need to be using if this is not accepted.

I call that file because withput it I get a

Fatal error: Call to undefined function error

Thanks

Warwick


HontoNoRoger on "Pagination incorrect for NextGEN Gallery"

0
0

Hello,

I have a bug, which doesn't display the right amout of image pages for a thumbnail gallery.
http://japanblog.jp.pn/bilder/japan-2010/ should have about 51 pages, only 17 are visible.

After some trial & error debugging I found out, that the $total variable in
nextgen-gallery\products\photocrati_nextgen\modules\nextgen_pagination\mixin.nextgen_basic_pagination.php is not using the maximum image count from the database, which I changed to 1600 and saved it, but the default value of 500, which makes it 500 pictures / 30 images per site = 17.

But you can get to the other pages if you change the URL manually.

I'm using WordPress 3.8 with NextGEN Gallery by Photocrati 2.0.40.

Could somebody with knowledge on the code please look into it? Thanks!

alev on "Need you asistance"

0
0

Hi
A question
i have a form that include credit card processing
We have ssl but I have a problem pointing page
I need to change permlink for one page from http to https (ssl)
Any idea hot can I do it.
You assistance is appreciated.

geofflaskey87 on "Woocommerce - Add Shipping Phone Number"

0
0

I'm trying to add a shipping phone number to my woocommerce checkout page. I've got the field added with the code supplied. I need to get it to pull through to woocommerce in the admin area, so when orders are sent I can give fed-ex the shipping phone number (it's overnight crab shipping, so they need to be able to contact the recipient.)

here's the code I got from woocommerce

// Hook in
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

// Our hooked in function - $fields is passed via the filter!
function custom_override_checkout_fields( $fields ) {
     $fields['shipping']['shipping_phone'] = array(
        'label'     => __('Phone', 'woocommerce'),
    'placeholder'   => _x('Phone', 'placeholder', 'woocommerce'),
    'required'  => false,
    'class'     => array('form-row-wide'),
    'clear'     => true
     );

     return $fields;
}

Smebagi on "Export custom post taxonomy categories"

0
0

Does anybody have a solution for exporting custom post taxonomy categories.

The current Export function in tools allows the selection of a custom post type but will only export those categories associated to the posts.

Artika The Bastet on "Paginate reply on any pages same articles...."

RDStudent on "Page Navigation Next Prev"

0
0

Hello,
I am wondering if someone can help me out. I have a custom-page-template that uses this query:

<?php // The Query
      query_posts( array ('category_name' => 'for-sale', 'posts_per_page' => 2) ); ?>

And these controlls

<?php global $wp_query;
       if($wp_query->max_num_pages > 1) :?>

<?php previous_posts_link('&larr; Previus Page', $wp_query->max_num_pages);?>
<?php next_posts_link('Next Page &rarr;', $wp_query->max_num_pages);?>

Issue I am getting is that, Next and Prev works fine. I always get correct number of pages and all but my content always stays the same.

I figured issue is every time the page reloads on Next and Prev, query runs and gets first X number of items.

I am wondering how I can do this and if this is even possible to do:
I am thinking to create a global control variable X like +1 -1, that will be incremented and decremented by Next and Prev buttons.

Now when the page loads I would say wp_guery(indexOf X).

Is this possible ?

A31 on "Nested Select Menu"

0
0

Hi,
I am really struggling to get a second dropdown / select box to be automatically populated and I hope someone here can help me find my mistake.

Before moving to Wordpress, I have been using the example by W3Schools but now in wordpress, I can't seem to get it working.

My Code is as follows:

<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","Fin_GetAllocation.php?q="+str,true);
xmlhttp.send();
}
</script>
<form>
	<select name="sel_CostCentre" id="sel_CostCentre" onchange="showUser(this.value)">
		<option value=0>Please Select Cost Centre: <?php echo $CostCentreDescriptionOptions; ?>
	</select>
    <select name="Sel" id="txtHint"></select>
</form>

then the code in the file "Fin_GetAllocation.php" is as follows:

<?php
	global $wpdb;

	$q=$_GET["q"];

	$SQL_Query01 = ("SELECT * FROM wp_allocations_tbl WHERE CostCentreDescription = '$q'");
	$SQL_Results01 = $wpdb->get_results($SQL_Query01);

	foreach($SQL_Results01 as $myResult01)
		{
			$AccountDescription = $myResult01->AccountDescription; //Field in DB
			$AccountDescriptionOptions.="<option value='$AccountDescription'>" . $AccountDescription . "</option>";
		}

So my first dropdown / select box works perfectly, but I can't seem to get the second box to populate.

Can you please help?


Nagytalp on "Display custom taxonomy part as "label on image" @home"

0
0

Hi!

I have this code:

< ?php
$p_terms = get_the_terms( $post->ID , 'tagportfolio' );
print_r($p_terms);
if ( $p_terms && ! is_wp_error( $p_terms ) ) {
$term_links = array();
foreach ( $p_terms as $p_term ) {
$term_links[] = $p_term->name;
}
$termslinks = join( ", ", $term_links );
echo '
'.$termslinks.'

';
}
?>

I wanna show the name of the custom taxonomy on the featured image on my home page as a clickable label. This code is works and the solution is inside of the but I don't know where.

At this moment the result look like this:

Array ( [6] => stdClass Object ( [term_id] => 6 [name] => Allegro [slug] => allegro [term_group] => 0 [term_taxonomy_id] => 45 [taxonomy] => tagportfolio [description] => Zene-bona [parent] => 0 [count] => 5 [object_id] => 1342 [filter] => raw ) ) Allegro

What I need is the last word! In this case the "Allegro".

And if can anybody tell me the perfect code for the solution then how can I style this label?

Another problem is in this case: When mouse over on this "result" the whole picture flashes extremly fast.

My site is here: http://www.irodalmibableves.hu

Thank You!

bbatie on "Using add_action on login to set localstorage"

0
0

I am using the add_action with wp_login to set a localstorage item on login. Its working fine when I try to login at the wp-admin page but instead of going through with the login it goes to the wp-login.php and is just a blank page. Any ideas on this?

Here is my actual code:

function set_storage_yes()
{
echo '<script type="text/javascript">window.localStorage.setItem(\'loggedIn\', \'true\');              </script>';

}
add_action('wp_login', 'set_storage_yes', 10);

vinoth06 on "Set Cookies on Form Load"

0
0

Hi,
Am developing a plugin, In that a form will appear as a widget in the website. When user fills and give submit that form should disappear.

What I planned is after form submit the cookie will set. If cookie set then the form should not display else it should display.

I tried by setting cookies, but not able to success. In wordpress Cookies can set only at
add_action( 'init',name);

So while page load the cookie is set. So not able to succeed.

Kindly Suggest me.

ncj on "Find/replace on pagination using PHP"

0
0

I'm trying to do a find/replace on the pagination links using PHP but am having trouble putting this code into a variable so that I can do a basic str_replace command. Can anyone recommend a way to do this?

This is the code rendering the pagination:
<?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>

SpidermanPuddin on "Custom Select Query doubles posts"

0
0

Custom Select query will SOMETIMES double the post. Meaning it'll display the same post twice, consecutively. It only does it on certain term ids. Here's the query

$querystr = "
			SELECT COUNT(ID)
			FROM $wpdb->posts
			LEFT JOIN $wpdb->postmeta AS date_value
				ON($wpdb->posts.ID = date_value.post_id
				AND date_value.meta_key = 'date_value')
	  		INNER JOIN  $wpdb->term_relationships
	              ON (wp_posts.ID = $wpdb->term_relationships.object_id)
	  		INNER JOIN  $wpdb->term_taxonomy
	              ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
	        INNER JOIN  $wpdb->terms
	              ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id)
			WHERE $wpdb->posts.post_status = 'publish'
				AND $wpdb->posts.post_type = 'custom_post'
				AND date_value.meta_value >= '" . date('Ymd') . "'
				AND $wpdb->terms.term_id IN ( $term->term_id )
	";
	$result = mysql_query($querystr) or die(mysql_error());
	// Print out result
	while($row = mysql_fetch_array($result)){
		$gs_count = $row['COUNT(ID)'];
	}
	unset($querystr);

I've only been able to fix this by deleting the post(s) and republishing them.

gman243 on "Looking for a Google+ Feed Widget"

0
0

Hey all, I hope this is the right forum!

I'm trying to incorporate a simple Google+ profile feed widget on a clients website. A Wordpress plugin is preferable but after searching Google all I can find are third party services that will generate an RSS feed for you based on your profile. For some of them you even have to create an app while being logged into the Google+ account you want to use, edit a few settings, fill in a few fields, save the app and then enter the app information into the widget.

Is there not a simple way to get a feed without jumping through all these hoops? It seems ridiculously complicated when Google could simply add an RSS feed for their users profiles.

I'm not looking to code anything or write my own app. I want a simple out-of-the-box solution and I'm quite surprised one doesn't exist. I may have to tell my client to scrap the Google+ feed entirely.

Thanks!

speedwheel on "woocommerce - is_product_subcategory()"

0
0

Hello, any body knows how to create a condition for subcategory pages same like is_product_category() in woocommerce?


dermattes on "PHP Value in Nextgen Shortcode"

0
0

Hello everybody!

I want to call a Nextgen Gallery via a shortcode. In this shortcode i want to put a php value which i get from a custom field.
The value and the shortcode work on its own, but the combination doesn't seem to work.

<?php
$nggid = the_field('gallerie');
$shortcode = "[ngg_images gallery_ids='{$nggid}' display_type='photocrati-nextgen_basic_slideshow']";
echo do_shortcode($shortcode);
?>

Gives out: "4Gallery not found. Please check your settings."
(the "4" is the custom field value)

Since i am not really literate in PHP, i hope that there is just a minor mistake that someone else can easily identify.

Thanks in advance!
Mattes

chaos67731 on "Make multiple pages and set template/content on theme activation?"

0
0

OK, I have two different code and I need them mixed together more or less.

I want to be able to make 5 or 6 pages on a site when my theme is activated.

When it makes the pages, I want it to set the template that that page will use and set content to that page.

Here is code I have that will just make more than one page.

function create_initial_pages() {
    $pages = array(
        'page1' => 'Page 1',
        'page2' => 'Page 2',
        'page3' => 'Page 3',
        'page4' => 'Page 4'
    );
    foreach($pages as $page_url => $page_title) {
        $id = get_page_by_title($page_title);
        $page = array(
            'post_type'   => 'page',
            'post_name'   => $page_url,
            'post_title'  => $page_title,
            'post_status' => 'publish',
            'post_author' => 1,
            'post_parent' => ''
        );
        if (!isset($id)) wp_insert_post($page);
    };
}

Here is code that will make only one page but set the content and template that page should have.

if (isset($_GET['activated']) && is_admin()){
        $new_page_title = 'Sitemap';
        $new_page_content = ' ';
        $new_page_template = 'sitemap.php'; //ex. template-custom.php. Leave blank if you don't want a custom page template.
        //don't change the code bellow, unless you know what you're doing
        $page_check = get_page_by_title($new_page_title);
        $new_page = array(
                'post_type' => 'page',
                'post_title' => $new_page_title,
                'post_content' => $new_page_content,
                'post_status' => 'publish',
                'post_author' => 1,
        );
        if(!isset($page_check->ID)){
                $new_page_id = wp_insert_post($new_page);
                if(!empty($new_page_template)){
                        update_post_meta($new_page_id, '_wp_page_template', $new_page_template);
                }
        }
}

Thanks

squizeers on "Get the large image of the gallery image"

0
0

I am using the following code to loop through the galley images in the post

<?php
$galleries = get_post_galleries_images( $post );
foreach( $galleries as $gallery ) {
 // Loop through each image in each gallery
 foreach( $gallery as $image ) {
  $image_list .= '<a href="'.'LINK TO LARGE IMAGE'.'"><img src="'. $image .'"/></a>';
 }
}
echo $content .= $image_list;
?>

How do I get the link to large image of the gallery image so that I can replace "LINK TO LARGE IMAGE" in the above code with it?

Any help is be much appreciated

vinoth06 on "Error on Plugin Activation"

0
0

Hi, I have developed new plugin from scratch, At that time it worked fine. But now I have tried to install in another site am getting this error.

The plugin generated 130 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin.

Could any one please give some suggestion.

Am working in Widget and Setting Page. The output of the widget will be displayed in Sidebar.

You can see the coding and screenshots,
http://buffercode.com/wordpress-website-rating-plugin/

Skyrie on "Widgets in Admin Bar"

0
0

Can anyone tell me how I can add widgets to the admin bar?

I've created the widget area and added a custom menu to the admin bar (via the add_menu API), but I'm not sure how to add the PHP code to call the widget area inside of the add_menu function. I'm not the best with PHP so any advice or snippets would be appreciated. Thanks.

Viewing all 8245 articles
Browse latest View live




Latest Images