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

Jon W on "Showing only the last 3 comments for a post / page"

$
0
0

For my mobile theme I wish to show only the last 3 comments for that post (or page) and the new comment form.

I added this code to the comments.php

<?php $args = array(
    'number' => 3,
    'post_id' => $post->ID,
    'status' => 'approve'
);
$latest_comment = get_comments( $args );
if( $latest_comment ) foreach( $latest_comment as $comment ) { ?>
<?php echo $comment->comment_author; ?>: <?php echo wp_html_excerpt( $comment->comment_content, 500 ); ?>..."<br /><br />
<?php } ?>
</p>
<p>
To read all questions and answers view the website on a desktop or tablet.
</p>
<p>
<b>Ask a Question / Leave a Comment:</b>
</p>
<?php comment_form(array('comment_notes_after' => '')); ?>

However, this shows the last 3 comments for the whole site, not for that page. Better than showing all comments (some pages have hundreds) but not what I wanted to do.

Does anybody know how to get the current page comments to show?

Many thanks

Jon.


zapping on "unknow page access"

$
0
0

On our google analytics account actually we are seeing some sort of access to non-existing pages from Philippines. How can it be checked if its some sort of an issue or hack.

kikimarie123 on "Share Content - External Links Generate Excerpt Thumbnail"

$
0
0

Is there a plugin out there that allows you to insert a link from any site and then it generates a thumbnail and excerpt. Just how when you insert a link on Facebook or LinkedIn, the thumbnail from the source and an excerpt of the post/article generates.

I'm developing a community-based (private) website, via Buddypress, and I want users to be able to share links to interesting articles but I don't want it to be just a link. It would look weird and tacky. I was going to make an option to upload a PDF but I'd much rather have the Facebook/LinkedIn style of sharing external links.

Anyone have any ideas? I've searched high and low...

SV_ChrisM on "PhP web service"

$
0
0

I'm working with a Woocommerce install and I want to have a remote .NET server create coupons on our web store on command.

To this end, I'm trying to set up a PhP web service that will create a coupon programmatically. I've got the basic framework set up, but I'm not sure how to call Woocommerce from a listener script. Can I just make woocommerce calls? Or do I have to import wordpress somehow?

Sorry if this is a noob question, I haven't really done any php programming directly.

jasonsweb on "wp_localize_script"

$
0
0

Hi!

I'm trying to get a like script running on my blog.

This is a part of the code, which I placed in my functions.php:

wp_localize_script('like_post', 'ajax_var', array(
	'url' => admin_url('admin-ajax.php'),
	'nonce' => wp_create_nonce('ajax-nonce')
));

But when I run it in debug mode, the following error appears:

wp_localize_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.

I've did many searches, but could only find solutions about "wp_enqueue_script", but unfortunately not about "wp_localize_script".

So is there something I'm doing wrong what makes the error appears?

Thanks in advance!

pcg4m3s on "Post a new comment using XML-RPC from java Android"

$
0
0

Hi,
for my Android application I need a way to post comment to a wordpress forum.

In my test main I do:

public static void main(String[] args) {
		// TODO Auto-generated method stub

		String xmlRpcUrl = "http://myURL/xmlrpc.php";

		try {
			XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
			config.setServerURL(new URL(xmlRpcUrl));
			XmlRpcClient client = new XmlRpcClient();
			client.setTransportFactory(new XmlRpcCommonsTransportFactory(client));
			client.setConfig(config);

			int blog_id=1;
			String username = "user";
			String password = "pass";
			int post_id=2;
			Comment comment=new Comment(0, "my comment", null, null, null);

			Object[] params = new Object[]{blog_id, username, password, post_id, comment};
			int comment_id = (int)client.execute("wp.newComment", params);
			System.out.println("COMMENT ID: "+comment_id);

		} catch (XmlRpcException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

Where Comment is my support class:

public class Comment {

	int comment_parent;
	String content;
	String author;
	String author_url;
	String author_email;

	public Comment(int comment_parent, String content, String author, String author_url, String author_email)
	{
		super();
		this.comment_parent = comment_parent;
		this.content = content;
		this.author = author;
		this.author_url = author_url;
		this.author_email = author_email;
	}
}

When I run this programa I have Exception:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/httpclient/methods/RequestEntity
	at org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory.getTransport(XmlRpcCommonsTransportFactory.java:38)
	at org.apache.xmlrpc.client.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:56)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:167)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:137)
	at org.apache.xmlrpc.client.XmlRpcClient.execute(XmlRpcClient.java:126)
	at Prova4.main(Prova4.java:36)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.httpclient.methods.RequestEntity
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.net.URLClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 6 more

Can you Help me?
Thanks!!

gerberto on "Shorten image URLS by removing /wp-content/uploads/"

$
0
0

Hi – I am trying to hide or shorten the URL of files or pictures uploaded to the /wp-content/uploads/ folder.

By default in WordPress if you upload an image, pdf, etc and insert it into a post or page it will have a link like this:
"http://www.mysite.com/wp-content/uploads/2013/05/picture.jpg"

I would rather the URL looks like this:
"http://www.mysite.com/2013/05/picture.jpg"

Is there a plugin or some hack that will let me hide the "wp-content/uploads" from showing up in my urls?

Thanks!

vimes1984 on "Woocommerce purchase note?"

$
0
0

I think i am missing something glaringly obvious here:
I am trying to include the pruchase note in the customer-completed-order.php so the customer recives the note along with the pruchase confirmation. but i am failing miserably.
here is what i have tried:

<?php echo '<div class=\"product-purchase-note\">'. $purchase_note . 'PURCHASE NOTE</div>'; ?>

`<?php $purchase_note = get_post_meta( $_product->id,'_purchase_note');
echo '<div class="product-purchase-note">' . $purchase_note . '</div>';
?>`
and this:

` <?php
$purchase_note = get_post_meta( $_product->id, '_purchase_note', true)) :
echo '<td class="product-purchase-note">' . apply_filters('the_content', $purchase_note) . '</td>';
?>`

and this:

<?php 		if ($order->status=='completed' || $order->status=='processing') {
					if ($purchase_note = get_post_meta( $_product->id, '_purchase_note', true))
						echo '<div class="product-purchase-note"><div>' . apply_filters('the_content', $purchase_note) . '</div></div>';
				} ?>

nothing seems to work....
it shows up on the order-received page but will not show on the order confirmed email.
Any help is much apricated I am also open to some other method to get the note to the client upon purchase.
such as custom meta values maybe??
Chris


MatthewRuddy on "Image Resizing Function - An Alternative to Timthumb"

$
0
0

Hey all. I've been working hard on updating my plugin the 'Easing Slider'. A fairly massive update is on the way, and being a slideshow plugin image resizing is always a hot topic.

I had been using Timthumb (like a lot of people), but often spent quite a while looking for a WordPress based alternative. I came across the 'vt_resize' function, which initially I felt did the trick, until I found out it wouldn't upscale images (which was vitally needed). It wasn't a good enough solution.

So I bit the bullet and decided to come up with my own function. It is heavily based on some of WordPress's internal resizing functions, except it crops identically to Timthumb itself.

It also supports the upcoming WordPress 3.5 update (an alternative function is used via an 'if' statement), which gives us access to some handy image manipulation classes to ease the pain.

So far after a bit of testing it appears to be working very well. I'm really happy with it. It saves the resized images in the WordPress uploads folder, as per usual. This is great, because not only are the images resized but they are static files, which is ideal.

I've created a Github page for the function here. It is released under GNU general public license, so feel free to use it as you wish!

http://matthewruddy.github.com/Wordpress-Timthumb-alternative/index.html

There is only one drawback: it won't work with external images. It's just too complicated and slow to do so, and probably not worth the effort. If you need to resize an external image, save it to your computer and upload it to the WordPress Media Library. Then use it from there.

That's it really. If anyone finds any bugs, then let me know and I'll get them sorted quickly!

Now you've no excuse to use Timthumb at all!

celo1910 on "this appearing erro_log"

$
0
0

hello people can someone help me this error appearing frequentimente how can I resolve this error
[20-Jun-2013 05:50:04 UTC] Error WordPress database Lost connection to MySQL server During query for query SELECT option_value FROM wp_options WHERE option_name = 'wpseo_internallinks' LIMIT 1 made by require (' wp-blog -header.php '), require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' plugins_loaded ') call_user_func_array, wpseo_init , get_wpseo_options, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database Lost connection to MySQL server During query for query SELECT option_value FROM wp_options WHERE option_name = 'widget_pages' LIMIT 1 made by require (' wp-blog -header.php '), require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' init '), call_user_func_array, wp_widgets_init , do_action ('widgets_init') call_user_func_array, WP_Widget_Factory-> _register_widgets, WP_Widget-> _register, WP_Widget-> get_settings, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'widget_tag_cloud' LIMIT 1 made by require ('wp-blog-header . php ') require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' init '), call_user_func_array, wp_widgets_init, do_action ('widgets_init') call_user_func_array, WP_Widget_Factory-> _register_widgets, WP_Widget-> _register, WP_Widget-> get_settings, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'widget_akismet_widget' LIMIT 1 made by require ('wp-blog-header . php ') require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' init '), call_user_func_array, wp_widgets_init, do_action ('widgets_init') call_user_func_array, WP_Widget_Factory-> _register_widgets, WP_Widget-> _register, WP_Widget-> get_settings, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query
SELECT wp_term_taxonomy.term_id
FROM wp_term_taxonomy
INNER JOIN wp_terms USING (term_id)
WHERE taxonomy = 'category'
Wp_terms.slug AND IN ('www-theps2torrents-blogspot-com')
made by require ('wp-blog-header.php'), wp, WP-> main, WP-> query_posts, WP_Query-> query, WP_Query-> get_posts, WP_Tax_Query-> get_sql, WP_Tax_Query-> clean_query, WP_Tax_Query-> transform_query
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' AND t.slug = 'www-theps2torrents-blogspot-com' LIMIT 1 made by require ('wp-blog-header.php'), wp, WP-> main, WP -> query_posts, WP_Query-> query, WP_Query-> get_posts, get_term_by
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT SQL_CALC_FOUND_ROWS distinct wp_posts.ID FROM wp_posts WHERE 1 = 1 AND 0 = 1 AND wp_posts.post_type = ' post 'AND (wp_posts.post_status =' publish ') GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 10 made by require (' wp-blog-header.php '), wp, WP-> main, WP -> query_posts, WP_Query-> query, WP_Query-> get_posts
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' AND t.slug = 'www-theps2torrents-blogspot-com' LIMIT 1 made by require ('wp-blog-header.php'), wp, WP-> main, WP -> handle_404, WP_Query-> get_queried_object, get_term_by
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT wp_posts. * FROM wp_posts WHERE 1 = 1 AND wp_posts.post_name = 'www-theps2torrents-blogspot- with 'AND wp_posts.post_type =' post 'AND (wp_posts.post_status =' publish ') ORDER BY wp_posts.post_date DESC made by require (' wp-blog-header.php '), require_once (' wp-includes/template- Loader.php ') do_action (' template_redirect ') call_user_func_array, smart404_redirect, get_posts, WP_Query-> query, WP_Query-> get_posts
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT wp_posts. * FROM wp_posts WHERE 1 = 1 AND wp_posts.post_name = 'www-theps2torrents-blogspot- with 'AND wp_posts.post_type =' page 'AND (wp_posts.post_status =' publish ') ORDER BY wp_posts.post_date DESC made by require (' wp-blog-header.php '), require_once (' wp-includes/template- Loader.php ') do_action (' template_redirect ') call_user_func_array, smart404_redirect, get_posts, WP_Query-> query, WP_Query-> get_posts
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND t.name LIKE '% http://www.theps2torrents.blogspot.com' AND tt.count> 0 ORDER BY t.name ASC made by require ('wp-blog-header . php ') require_once (' wp-includes/template-loader.php ') do_action (' template_redirect ') call_user_func_array, smart404_redirect, get_tags, get_terms
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') AND t.name LIKE 'www.theps2torrents.blogspot.com%' ORDER BY t.name ASC made by require ('wp-blog-header.php'), require_once ('wp-includes/template-loader.php') do_action ('template_redirect') call_user_func_array, smart404_redirect, get_categories, get_terms
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT wp_posts.ID FROM wp_posts WHERE 1 = 1 AND (((wp_posts.post_title LIKE '% www. theps2torrents.blogspot.com% ') OR (wp_posts.post_content LIKE'% http://www.theps2torrents.blogspot.com% '))) AND (wp_posts.post_password ='') AND wp_posts.post_type =' post 'AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 5 made by require ('wp-blog-header.php'), require_once ('wp-includes/template-loader.php') do_action ('template_redirect' ), call_user_func_array, smart404_redirect, smart404_search, get_posts, WP_Query-> query, WP_Query-> get_posts
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT wp_posts.ID FROM wp_posts WHERE 1 = 1 AND (((wp_posts.post_title LIKE '% www. theps2torrents.blogspot.com% ') OR (wp_posts.post_content LIKE'% http://www.theps2torrents.blogspot.com% '))) AND (wp_posts.post_password ='') AND wp_posts.post_type =' page 'AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC LIMIT 0, 5 made by require ('wp-blog-header.php'), require_once ('wp-includes/template-loader.php') do_action ('template_redirect' ), call_user_func_array, smart404_redirect, smart404_search, get_posts, WP_Query-> query, WP_Query-> get_posts
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'ace_page_sections_' LIMIT 1 made by require ('wp-blog-header . php ') require_once (' wp-includes/template-loader.php '), include (' / themes/GamesWorld/404.php '), get_header, locate_template, load_template, require_once (' / themes / Gamesworld / header. php '), wp_nav_menu, call_user_func, menu_1_default, wp_list_pages, apply_filters (' wp_list_pages_excludes') call_user_func_array, ace_list_pages_excludes, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT * FROM wp_posts WHERE (post_type = 'page' AND post_status = 'publish') ORDER BY menu_order ASC made by require ('wp-blog-header.php'), require_once ('wp-includes/template-loader.php'), include ('/ themes/GamesWorld/404.php'), get_header, locate_template, load_template, require_once ('/ themes / Gamesworld / header.php'), wp_nav_menu, call_user_func, menu_1_default, wp_list_pages, get_pages
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') AND (t.term_id <> 1) ORDER BY t.name ASC made by require ('wp-blog-header.php'), require_once ('wp-includes / template-Loader.php '), include (' / themes/GamesWorld/404.php '), get_header, locate_template, load_template, require_once (' / themes / Gamesworld / header.php '), wp_nav_menu, call_user_func, menu_2_default, wp_list_categories, get_categories, get_terms
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') AND tt.count> 0 ORDER BY t.name ASC made by require ('wp-blog-header.php'), require_once ('wp-includes/template-loader . php ') include (' / themes/GamesWorld/404.php '), get_sidebars, get_sidebar, locate_template, load_template, require_once (' / themes / Gamesworld / sidebar.php '), dynamic_sidebar, call_user_func_array, WP_Widget-> display_callback, WP_Widget_Categories-> widget, wp_list_categories, get_categories, get_terms
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT t. * Tt. * FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category') ORDER BY t.name ASC made by require ('wp-blog-header.php'), require_once ('wp-load.php'), require_once ('wp- config.php '), require_once (' wp-settings.php '), include (' / themes / Gamesworld / functions.php '), cats_to_select, get_categories, get_terms
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'widget_pages' LIMIT 1 made by require (' wp-blog-header . php ') require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' init '), call_user_func_array, wp_widgets_init, do_action ('widgets_init') call_user_func_array, WP_Widget_Factory-> _register_widgets, WP_Widget-> _register, WP_Widget-> get_settings, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'widget_tag_cloud' LIMIT 1 made by require ('wp-blog-header . php ') require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' init '), call_user_func_array, wp_widgets_init, do_action ('widgets_init') call_user_func_array, WP_Widget_Factory-> _register_widgets, WP_Widget-> _register, WP_Widget-> get_settings, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'widget_akismet_widget' LIMIT 1 made by require ('wp-blog-header . php ') require_once (' wp-load.php '), require_once (' wp-config.php '), require_once (' wp-settings.php ') do_action (' init '), call_user_func_array, wp_widgets_init, do_action ('widgets_init') call_user_func_array, WP_Widget_Factory-> _register_widgets, WP_Widget-> _register, WP_Widget-> get_settings, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT ID, post_name, post_parent, post_type FROM wp_posts WHERE post_name IN ('porn', 'wp-content ',' uploads', '2012 ', '11', 'Watermelon-png') AND (post_type = 'page' OR post_type = 'attachment') made by require ('wp-blog-header.php'), wp , WP-> main, WP-> query_posts, WP_Query-> query, WP_Query-> get_posts, WP_Query-> parse_query, get_page_by_path
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = 'ace_settings_onlyinwidget' LIMIT 1 made by require ('wp-blog-header . php '), wp, WP-> main, WP-> query_posts, WP_Query-> query, WP_Query-> get_posts, apply_filters_ref_array, call_user_func_array, ace_where, get_option
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT distinct wp_posts. * FROM wp_posts WHERE 1 = 1 AND (wp_posts.ID = '0 ') AND wp_posts.post_type = 'page' ORDER BY wp_posts.post_date DESC made by require ('wp-blog-header.php'), wp, WP-> main, WP-> query_posts, WP_Query-> query, WP_Query-> get_posts
[20-Jun-2013 05:50:04 UTC] Error WordPress database MySQL server has gone away for query SELECT ID FROM wp_posts WHERE post_name LIKE '%

maustin89 on "Exclude a custom post type from HTML sitemap"

$
0
0

Hi guys, I created a page template for an HTML sitemap based on Yoast's post here: http://yoast.com/html-sitemap-wordpress/

The below snippet is used to display custom post types in the sitemap:

<?php
foreach( get_post_types( array('public' => true) ) as $post_type ) {
  if ( in_array( $post_type, array('post','page','attachment') ) )
    continue;

  $pt = get_post_type_object( $post_type );

  echo '<h2>'.$pt->labels->name.'</h2>';
  echo '<ul>';

  query_posts('post_type='.$post_type.'&posts_per_page=-1');
  while( have_posts() ) {
    the_post();
    echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  }

  echo '</ul>';
}

My problem is I'm using the WCK CPT Creator plugin and it apparently auto-generates a post type for custom meta boxes, because I'm getting a "WCK Custom Meta Boxes" section at the bottom of my sitemap below the other CPTs. I can't see any way to remove this in the plugin's interface. Can anyone suggest how to modify the above code to exclude a given post type?

Thanks!

paulhume on "Page Protection Password"

$
0
0

I have a need for the password to time out a lot quicker for protected pages in a wordpress site.

In older versions of WP I would edit the wp_pass.php file to achieve this. After the 3.4.1 update WP does not use this file anymore.

Does anyone know how I can change the timeout value on the page protection passwords?

Thank you in advance for your help.

Regards

Paul

Hubert Nguyen on "Is it possible to know the page type when "send_headers" Action is called?"

$
0
0

Hello,

I would like to setup custom HTTP cache-control headers depending on the type of pages. I thought that I could use the "send_headers" action hook to do that, but unfortunately, it seems that when this hook is called, Wordpress does not yet know what type of page it is dealing with, and therefore is_attachment(), is_author(), is_single(), is_category(), is_tag(), is_feed() and is_home() all return "false".

Did I miss something? This would be very handy since not all types should be cached for the same length of time. In theory, once "send_headers" has been called, it's not possible to send additional header information.

Thank you!

WillBontrager on "How to reverse effect of wpautop() and wptexturize() on multi-line shortcode"

$
0
0

I have a short code with multi-line content.

Functions wpautop() and wptexturize() are applied to the shortcode content before my plugin gets a copy of it. The content of this shortcode:

[shortcode]
His name is "Able."
The ball's shape is spherical.
[/shortcode]

Becomes:

<br />
His name is & #8220;Able.& #8221;<br />
The ball& #8217;s shape is spherical.<br />

(Sorry, had to put a space between & and # for entities code to publish.)

How do I reverse the effect of wpautop() and wptexturize()?

For the nonce, I'm putting the shortcode content into pre tags with the plugin stripping out the pre tags before using it.

The content of this shortcode:

[shortcode]
<pre>
His name is "Able."
The ball's shape is spherical.
</pre>
[/shortcode]

Becomes:

His name is "Able."
The ball's shape is spherical.

I don't like the "use pre tag" solution. It seems so inelegant and there may be issues with it I have not yet encountered.

Does anyone know how to reverse the effects wpautop() and wptexturize() have on shortcode content?

Will

everyeurocounts on "$wpdb Inner Join"

$
0
0

I am trying to create a array of postdates where the post meets a custom taxonomy criteria (location) this will also be modified by a form element (will be using Ajax hopefully) but im stuck on creating the array.

Basically using INNER JOIN to match the two tables and select the postdate from wp_posts where the taxomomy id = 3 (this links to another table with the text format of the taxonomy name).

$fdates = $wpdb->get_results("SELECT post_date FROM wp_posts INNER JOIN wp_term_realtionships
		ON wp_terms_relationships.object_id=wp_posts.object_id
		WHERE wp_terms_relationships.term_taxonomy_id = 3");

it just returns array() using print_r function.
Localhost so no example :( Thanks in advance to anyone who can help me!


gombroo on "Custom post types and "fatal error: require_once() " message"

$
0
0

Hello,

I've registered some custom post types in my child theme. They are included in the directory: libs/posttypes.php and looks like this:

<?php
add_action('init', 'mamepro_init_posttypes');
function mamepro_init_posttypes() {

/* Register Announcements  */
        $announcements_args = array(
            'labels' => array(
                'name' => 'Ogłoszenia',
                'singular_name' => 'Ogloszenie',
                'all_items' => 'Wszystkie ogłoszenia',
                'add_new' => 'Dodaj nowe ogłoszenie',
                'add_new_item' => 'Dodaj nowe ogłoszenie',
                'edit_item' => 'Edytuj ogłoszenie',
                'new_item' => 'Nowe ogłoszenie',
                'view_item' => 'Zobacz ogłoszenie',
                'search_items' => 'Szukaj w ogłoszeniach',
                'not_found' =>  'Nie znaleziono żadnych ogłoszeń',
                'not_found_in_trash' => 'Nie znaleziono żadnych ogłoszeń w koszu',
                'parent_item_colon' => ''
            ),
            'public' => true,
            'publicly_queryable' => true,
            'show_ui' => true,
            'query_var' => true,
            'rewrite' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'menu_position' => 5,
            'supports' => array(
                'title','editor','author','thumbnail','excerpt','comments','custom-fields'
            ),
            'has_archive' => true
        );

        register_post_type('announcements', $announcements_args);
}
?>

I added a function to funcions.php file located in my child theme directory to make it work:

require_once MAMEPRO_THEME_DIR.'libs/posttypes.php';

But as a result I got an error message:

Warning: require_once(/home/marszand/domains/mamepro.org/public_html/wp-content/themes/path/libs/posttypes.php) [function.require-once]: failed to open stream: No such file or directory in /home/marszand/domains/mamepro.org/public_html/wp-content/themes/mamepro/functions.php on line 11

Fatal error: require_once() [function.require]: Failed opening required '/home/marszand/domains/mamepro.org/public_html/wp-content/themes/path/libs/posttypes.php' (include_path='.:/usr/local/php/p53/lib/php') in /home/marszand/domains/mamepro.org/public_html/wp-content/themes/mamepro/functions.php on line 11

I wonder why wordpress can't find posttypes.php and funcions.php files. If you can help me I'd be grateful!

Thanks in advance!

ikosweb on "How to separate data in wordpress metabox?"

$
0
0

just created a kind of long metabox using a tutorial at wptuts but I am lost in two things:

The output of the metabox displays all data grouped (ex. in grouped checkboxes they are all in a whole even if I have different groups) and I'd like to grab the titles of each group and display them in different tables, divs or blocks.

Don't know how to display the saved data in the post, and also display it in separate blocks.

My code is this:

$prefix = 'dbt_';
$meta_box = array(
'id' => 'features',
'title' => 'Property Features',
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
    array(
        'name' => 'Price (in USD)',
        'desc' => '',
        'id' => $prefix . 'text',
        'type' => 'text',
        'std' => ' '
    ),

      array(
        'name' => 'Price (in Mexican Peso)',
        'desc' => '',
        'id' => $prefix . 'text',
        'type' => 'text',
        'std' => ' '
    ),

    array(
        'name' => 'Address',
        'desc' => '',
        'id' => $prefix . 'textarea',
        'type' => 'textarea',
        'std' => ''
    ),

    array(
        'name' => 'Property for',
        'id' => $prefix . 'select',
        'type' => 'select',
        'options' => array('Sale', 'Rent', 'Vacational Rental')
    ),

    array(
        'name' => 'Area (m2)',
        'desc' => '',
        'id' => $prefix . 'text',
        'type' => 'text',
        'std' => ' '
    ),

    array(
        'name' => 'Area of terrain (m2)',
        'desc' => '',
        'id' => $prefix . 'text',
        'type' => 'text',
        'std' => ' '
    ),

    array(
        'name' => 'Number of rooms',
        'desc' => '',
        'id' => $prefix . 'text',
        'type' => 'text',
        'std' => ' '
    ),

    array(
        'name' => 'Number of bathrooms. Include half bathrooms (ex. 2 1/2)',
        'desc' => '',
        'id' => $prefix . 'text',
        'type' => 'text',
        'std' => ' '
    ),

    array(
        'name' => 'Service Bathroom',
        'id' => $prefix . 'checkbox',
        'type' => 'checkbox'
),

array(
        'name' => 'Furnished',
        'id' => $prefix . 'checkbox',
        'type' => 'checkbox'
),
array(
        'label' => 'Property specs',
        'desc'  => '',
        'id'    => $prefix.'checkbox_group',
        'type'  => 'checkbox_group',
        'options' => array (
        'one' => array (
        'label' => 'Livingroom',
        'value' => 'one'
    ),
        'two' => array (
        'label' => 'Diningroom',
        'value' => 'two'
    ),
        'three' => array (
        'label' => 'Breackfast area',
        'value' => 'three'
    ), 

        'four' => array (
        'label' => 'TV room',
        'value' => 'four'
    ),

        'five' => array (
        'label' => 'Studio',
        'value' => 'five'
    ),

        'six' => array (
        'label' => 'Integrated Kitchen',
        'value' => 'six'
    ),

        'seven' => array (
        'label' => 'Laundry Room',
        'value' => 'seven'
    ),

        'eight' => array (
        'label' => 'Service room',
        'value' => 'eight'
    ),

        'nine' => array (
        'label' => 'jacuzzi',
        'value' => 'nine'
    ),

        'ten' => array (
        'label' => 'terrace',
        'value' => 'ten'
    ),

        'eleven' => array (
        'label' => 'balcony',
        'value' => 'eleven'
    ),

        'twelve' => array (
        'label' => 'Warehouse',
        'value' => 'twelve'
    )
)
),  

    array(
        'label' => 'Installed',
        'desc'  => '',
        'id'    => $prefix.'checkbox_group',
        'type'  => 'checkbox_group',
        'options' => array (
        'one' => array (
        'label' => 'Air conditioner',
        'value' => 'one'
    ),
        'two' => array (
        'label' => 'Stationary gas',
        'value' => 'two'
    ),
        'three' => array (
        'label' => 'Water heater',
        'value' => 'three'
    ), 

        'four' => array (
        'label' => 'Hurricain shutters or hurricain protection',
        'value' => 'four'
    ),

        'five' => array (
        'label' => 'Telephone line',
        'value' => 'five'
    )
)
),

    array(
        'label' => 'Outdoors',
        'desc'  => '',
        'id'    => $prefix.'checkbox_group',
        'type'  => 'checkbox_group',
        'options' => array (
        'one' => array (
        'label' => 'Parking space',
        'value' => 'one'
    ),
        'two' => array (
        'label' => 'Garden',
        'value' => 'two'
    ),
        'three' => array (
        'label' => 'Pool',
        'value' => 'three'
    ), 

        'four' => array (
        'label' => 'Tennis court',
        'value' => 'four'
    ),

        'five' => array (
        'label' => 'Children playground',
        'value' => 'five'
    )
)
),

    array(
        'label' => 'Facilities',
        'desc'  => '',
        'id'    => $prefix.'checkbox_group',
        'type'  => 'checkbox_group',
        'options' => array (
        'one' => array (
        'label' => 'Spa',
        'value' => 'one'
    ),
        'two' => array (
        'label' => 'Gym',
        'value' => 'two'
    ),
        'three' => array (
        'label' => 'Party salon',
        'value' => 'three'
    ), 

        'four' => array (
        'label' => 'Snack-bar',
        'value' => 'four'
    )

)
),

    array(
        'label' => 'Luxury Features',
        'desc'  => '',
        'id'    => $prefix.'checkbox_group',
        'type'  => 'checkbox_group',
        'options' => array (
        'one' => array (
        'label' => 'Clubhouse',
        'value' => 'one'
    ),
        'two' => array (
        'label' => 'Dock',
        'value' => 'two'
    ),
        'three' => array (
        'label' => 'Waterfront',
        'value' => 'three'
    ), 

        'four' => array (
        'label' => 'Golf course',
        'value' => 'four'
    )

)
)

)
);

add_action('admin_menu', 'mytheme_add_box');
// Add meta box
function mytheme_add_box() {
global $meta_box;
add_meta_box($meta_box['id'], $meta_box['title'], 'mytheme_show_box', $meta_box['page'],    $meta_box['context'], $meta_box['priority']);
}

// Callback function to show fields in meta box
function mytheme_show_box() {
global $meta_box, $post;
// Use nonce for verification
echo '<input type="hidden" name="mytheme_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
echo '<div class="form-table">';
foreach ($meta_box['fields'] as $field) {
    // get current post meta data
    $meta = get_post_meta($post->ID, $field['id'], true);
    echo '<tr>',
            '<th style="width:20%"><label for="', $field['id'], '">', $field['name'], '</label></th>',
            '<td>';
    switch ($field['type']) {
        case 'text':
            echo '<input type="text" name="', $field['id'], '" id="', $field['id'], '" value="', $meta ? $meta : $field['std'], '" size="30" style="width:97%" />', '<br />', $field['desc'];
            break;
        case 'textarea':
            echo '<textarea name="', $field['id'], '" id="', $field['id'], '" cols="60" rows="4" style="width:97%">', $meta ? $meta : $field['std'], '</textarea>', '<br />', $field['desc'];
            break;
        case 'select':
            echo '<select name="', $field['id'], '" id="', $field['id'], '">';
            foreach ($field['options'] as $option) {
                echo '<option ', $meta == $option ? ' selected="selected"' : '', '>', $option, '</option>';
            }
            echo '</select>';
            break;
        case 'radio':
            foreach ($field['options'] as $option) {
                echo '<input type="radio" name="', $field['id'], '" value="', $option['value'], '"', $meta == $option['value'] ? ' checked="checked"' : '', ' />', $option['name'];
            }
            break;
        case 'checkbox':
            echo '<input type="checkbox" name="', $field['id'], '" id="', $field['id'], '"', $meta ? ' checked="checked"' : '', ' />';
            break;

// checkbox_group
case 'checkbox_group':
foreach ($field['options'] as $option) {
    echo '<input type="checkbox" value="'.$option['value'].'" name="'.$field['id'].'[]" id="'.$option['value'].'"',$meta && in_array($option['value'], $meta) ? ' checked="checked"' : '',' />
            <label for="'.$option['value'].'">'.$option['label'].'</label><br />';
}
echo '<span class="description">'.$field['desc'].'</span>';
break;    

    }
    echo     '</td><td>',
        '</td></tr>';
}
echo '</table>';
}

do_action('save_post', 'mytheme_save_data');
// Save data from meta box
function mytheme_save_data($post_id) {
global $meta_box;
// verify nonce
if (!wp_verify_nonce($_POST['mytheme_meta_box_nonce'], basename(__FILE__))) {
    return $post_id;
}
// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
    return $post_id;
}
// check permissions
if ('page' == $_POST['post_type']) {
    if (!current_user_can('edit_page', $post_id)) {
        return $post_id;
    }
} elseif (!current_user_can('edit_post', $post_id)) {
    return $post_id;
}
foreach ($meta_box['fields'] as $field) {
    $old = get_post_meta($post_id, $field['id'], true);
    $new = $_POST[$field['id']];
    if ($new && $new != $old) {
        update_post_meta($post_id, $field['id'], $new);
    } elseif ('' == $new && $old) {
        delete_post_meta($post_id, $field['id'], $old);
    }
}
}

// check autosave
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return $post_id;
}

DelarnMini on "Login form problem"

$
0
0

I've made a login form in my fixed-top navbar with The Bootstrap theme.

It works, I get logged in, but every times I hit F5 or refresh I get booted out and have to sign in again.

antpowerWD on "Videos Upload"

$
0
0

Hi, I'm building an app with wordpress, I've got a videos upload configured in wordpress in functions.php and present as its own seperate upload on the dashboard. The videos page is pointing at archive-videos.php and consequently I can hardcode whatever I like to be present as part of the theme and functionality of the page.

The problem I have is the videos upload on the dashboard isn't pointing at that page, when I upload videos it goes to a subdomain of videos and not to the actual videos page itself.

So I need it all hooked up from the code to the page to the dashboard, the code and the page are, but the dashboard and the page are not.

Quick reply appreciated.

Love the software by the way its been great fun learning it through doing this app for my client.....

Regards
Ant

Dubai Web Design - incirclemedia.com on "Solution to display recent posts from blog to website"

$
0
0
<?php
	$db_username = '#######';
	$db_password = '#######';
	$db_database = '#######';  

	$blog_url = 'http://www.#######.com/#######/blog/'; //base folder for the blog. Make SURE there is a slash at the end  

	//connect to the database
	$con = mysql_connect(localhost, $db_username, $db_password);
	@mysql_select_db($db_database) or die("Unable to select database");
	$query = "Select * FROM wp_posts WHERE post_type='post' AND post_status='publish' ORDER BY id DESC LIMIT 2";

	$query_result = mysql_query($query);  

	while($row = mysql_fetch_array($query_result))
    {
    ?>

    <div class="blog_cont"> <a>"><b><?php echo $row['post_title'] ?></b></a><br clear="all" />
      <span><?php if (strlen($row['post_content']) > 40) { echo substr($row['post_content'], 0, 120) . '...'; } ?></span> <a>">Read More »</a> </div>
    <?php }
	  @mysql_close($con);
	?>
Viewing all 8245 articles
Browse latest View live




Latest Images