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

Andy Mercer on "Call Media Editor Gallery Page Directly"

$
0
0

I'm calling the WP 3.5 media uploader from a metabox, and have gotten it working to select single or multiple images. What I'd really like to do is call it to the Gallery's page instead though, so that I can then click through to the sorting page, and be able to sort the images.

My current code is this:

jQuery('#fg_select').on('click', function(event){

		event.preventDefault();

		// If the media frame already exists, reopen it.
		if ( file_frame ) {
			file_frame.open();
			return;
		}

		// Create the media frame.
		file_frame = wp.media.frame = wp.media({
			title: "Select Images For Gallery",
			button: {text: "Select",},
			library : { type : 'image'},
			multiple: true // Set to true to allow multiple files to be selected
		});

		file_frame.on('open', function() {
			var selection = file_frame.state().get('selection');
			ids = jQuery('#fg_metadata').val().split(',');
			ids.forEach(function(id) {
				attachment = wp.media.attachment(id);
				attachment.fetch();
				selection.add( attachment ? [ attachment ] : [] );
			});
		});

		file_frame.on('ready', function() {
			// Here we can add a custom class to our media modal.
			// .media-modal doesn't exists before the frame is
			// completly initialised.
			$( '.media-modal' ).addClass( 'no-sidebar' );
		});

		// When an image is selected, run a callback.
		file_frame.on('select', function() {
			var imageIDArray = [];
			var imageHTML = '';
			var metadataString = '';
			images = file_frame.state().get('selection');
			images.each(function(image) {
				imageIDArray.push(image.attributes.id);
				imageHTML += '
<li><button></button><img id="'+image.attributes.id+'" src="'+image.attributes.url+'"></li>
';
			});
			metadataString = imageIDArray.join(",");
			if(metadataString){
				jQuery("#fg_metadata").val(metadataString);
				jQuery("#featuredgallerydiv ul").html(imageHTML);
				jQuery('#fg_select').text('Edit Selection');
				jQuery('#fg_removeall').addClass('visible');
			}
		});

		// Finally, open the modal
		file_frame.open();

	});

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Any ideas?


bahrt on "Removing specific images from RSS feed"

$
0
0

Hello,
We are starting to work with a customer who's buying our RSS2 feed and we need to send them the full contents of each post. We also want to send them the images included on each post, but as they are going to reproduce them on their side too, there are images which need to be stripped from the feed to avoid copyright issues. One solution I came up with is removing them based on pattern matching (either file name or description would be enough), but I just don't know how to implement it in Wordpress.
This post looks like what I need to do but it's too old and I don't know where to find the equivalent in our version: http://wordpress.org/support/topic/removing-images-from-rss-feed

Is this something that can be done? If so, how?

Thanks!
Sebastian

golazo on "How make to not add article in parent category in wordpress"

$
0
0

How transform parent category in title. I want to add article only in subcategory, and categories appear only as decoration.

Ex:

Category(5) //You can not add articles
Subcategory1(3) //You can add article
Subcategory2(2) //You can add article
Subcategory3(0) //You can add article

Category(2) //You can not add articles
Subcategory1(1)
Subcategory2(1)

I have this code:

$cat = $_POST['cat'];

$date = array(
'post_title' => $tite,
'post_content' => $des,
'post_status' => 'publish',
'post_category' =>array($cat),
'post_author' => $user_ID,
);

wp_insert_post($date);

and

<?php wp_dropdown_categories('orderby=name&hide_empty=0&show_count=1&show_option_none=All Category&class=categorie&hierarchical=1&name=cat'); ?>

allm on "pre_comment_approved, return values"

$
0
0

I am using the pre_comment_approved filter and it seems the return value of 0 does not function. A return value of 'spam' does what can be expected.

Any ideas?

This is what the codex says:
http://codex.wordpress.org/Plugin_API/Filter_Reference/pre_comment_approved

I did some checking:

A return value of '0' (not a defined return value!) does not work, which is fine.

A return value of false (not a defined return value!) has the result that the comment is not shown in the admin, while it is still in the database. There are 2 e-mails to moderate.

Jim R on "Trying to pass a WP variable to a file outside of WP"

$
0
0

I'm using jQuery (not a plugin) with HighCharts to create a bar graph based on information coming from my own data table. The data table is in the same database as my WP install. The bar graph is displayed on a WP Archive Page via an Include.

(I know close to zip about jQuery.)

The jQuery is calling data from data.php, which isn't hooked into my WP install. I need to get that data to match up to the following:

$player = single_tag_title("", false);

single_tag_title is basically a basketball player's name. From there, I'd use the query:

"SELECT * FROM a_playerRating
		 WHERE CONCAT(playerFirst,' ', playerLast) = '".$player."'"

So I can tell the jQuery to just get information relative to that player in my custom data table.

How do I get the information in single_tag_title onto data.php when it isn't part of any of my WP Pages?

brianfromme on "Stripped WP on Ubuntu 13.10 can't handle shortcodes"

$
0
0

On a fresh install of Ubuntu Server 13.10 on AWS, I add LAMP stack and enable mod_rewrite. Then install WP 3.8.1 and remove all plugins and themes, except for the "twentyfourteen" theme. With nothing else to interfere, I would expect to be able to use any of the standard shortcodes defined here: http://en.support.wordpress.com/shortcodes/

So, I add a page and put the following on it's own line from the Text view of the page creation:

[recipe title="Summer Pasta with Basil, Tomatoes and Cheese" servings="4-6" time="2hr 30mins" difficulty="easy"]

Then, I Update the page and view it, which is here:

http://ec2-54-196-201-111.compute-1.amazonaws.com/wp/bug/

None of the defined shortcodes work. I've turned on PHP error_log and find no errors from that page.

Sounds like a bug. Can someone suggest a way I can do more diagnostics?

thanks,
Brian

jillianmariegraphics on "Taxonomy Archive - Sort and Filter by Terms"

$
0
0

I've been struggling over this concept for days and am hoping to get some help as I am a beginner at using custom post types.

I'm setting up a site to display an inventory of showroom products.

Custom Post Type: Products

Taxonomies related and their terms:
Model Year (2014, 2013, 2012)
Manufacturer (Company 1, Company 2)
Condition (New, Used)

In the "New Products" archive, I want to display all products in "New" condition, ordered by their model year with 2014 displaying first.

I did try adding a custom field (year_model) to be able to orderby the meta_value, although this didn't work.

Here is the code I have so far to display all new models.

<?php get_header();
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
?>

<div id="container">
<div id="content">

<section id="post-<?php the_ID(); ?>">
<article>
<div class="entry-content clearfix">
		<h2 class="entry-title"><?php echo apply_filters( 'the_title', $term->name ); ?> Products</h2>
<?php
$locations_query = new WP_Query( array(
	  'post_type' => 'products',
	  'posts_per_page' => 15,
	  //'meta_key'      => 'year_model', // the meta key of custom field
          //'orderby'      => 'meta_value',
          //'order'         => 'ASC',
'tax_query' => array(
		  array(
 			 'taxonomy' => 'condition',
			 'field' => 'slug',
			 'terms' => 'new'
		)
	)
) );
// Display the custom loop
if ( $locations_query->have_posts() ): ?>
<ul class="posts">
<?php while ( $locations_query->have_posts() ) : $locations_query->the_post(); ?>
<li>
	<a href="<?php the_permalink(); ?>" rel="bookmark"><h2 class="entry-title"> <?php the_title(); ?></h2>
	<div class="post-featured-image"><?php the_post_thumbnail(); ?></div></a>
	</li>
	<?php endwhile; wp_reset_postdata(); ?>
</ul><!--// end entry-header -->
<?php endif; ?>
</div><!--entry-content-->
</article>
</section>
</div><!--content-->
</div><!--container-->

flmrms on "Make random posts limited by category"


grizzam on "$post variables aren't outputting any data inside custom plugin."

$
0
0

How can I use $post variables inside a custom plugin?

I've tried:

global $post;
echo $post->post_title;

and:

the_ID();

But none of them output any data. How can those variables work inside a custom plugin? Thanks.

Anna Johansson on "Prevent wp_redirect on edited tag"

$
0
0

What I'm trying to achieve is that when a user edits an existing term and submits the changes he or she isn't redirected back to the overview of terms on edit-tags.php, but instead stays on the same term edit screen.

Simply put, what I want is to change the $location to be the

$_REQUEST['_wp_http_referer']
value.

I've tried this but I can't get it to work coherently (and also it relies on private functions and classes so I was hoping to find a more future proof solution):

function hip_stay_on_edit_term_page() {
	if( function_exists( '_get_list_table' ) && class_exists( 'WP_Terms_List_Table' ) ) {
		global $pagenow;
		if( $pagenow == "edit-tags.php" ) {
				$hip_WP_Terms_List_Table = _get_list_table( 'WP_Terms_List_Table' );
				switch ( $hip_WP_Terms_List_Table->current_action() ) {
					case 'editedtag':
						wp_redirect( $_REQUEST[_wp_http_referer] );
						exit;
					break;
				}
		}
	}
}
add_action( 'wp', 'hip_stay_on_edit_term_page', 9999 );


Any ideas on how to solve this would be greatly appreciated!

elitel on "Send Confirmation link after successful register"

$
0
0

Hi,

Where would I begin if I want to send users an Email Confirmation Link after registration?

Right now,

1. after submitting registration form, user information will be stored immediately in the 'wp_users' table.
2. User login credentials will be sent in their email addresses.

I really can't determine how to delay the insert of values in wp_users then send a confirmation link , to lessen the emails that do not actually exist.

Thanks!

Riccardo on "Force download not working as expected"

$
0
0

On PHP I usually I use these lines of code to force a download:

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream', true, 200);
header('Content-Disposition: attachment; filename="MY_FILENAME"');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
ob_clean();
ob_flush();
flush();
readfile('MY_FILE_PATH');
exit();

Now I tried to include the WordPress enviroment to it simply adding this on top of it:

require_once(dirname(__FILE__) . '/wp-load.php');

But now instead of instantly opening the browser download file dialog, the script runs for minutes (this lasts more for bigger files, it looks like the server is downloading the file) then only after this the browser shows the download file dialog where the user could clicks OK and starts the real download.

If I comment out the WordPress include it works as expected.

I have to use it for remote files, but it looks the same also on local files.

I tried various combinations of output buffering cleaning, flushing and restarting too.

Any hint on what feature of WordPress could cause this?

lemonthirst on "displaying the number of active visitors on a single post"

$
0
0

Hi, i've searched/tested most of the plugins available in the repository for a plugin that can count how many users are online on a single post.

I want to display the number of active users reading that post(just that url not the whole site)
Ex. Hello World (2 active visitors)
Hello World 2 (5 active visitors)
and so on based on the number of visitors

Is there a plugin like this?

Valgav on "Soundcloud embed options"

$
0
0

I have some code in functions.php which adds options to my YT links. I want the same for my soundcloud. Is there any way to control this from functions.php? And if possible move adding video-frame only for YT videos.

Also soundcloud doesn't embed without including it in functions. Is it normal?

function Oembed_youtube_no_title($html,$url,$args){
    $url_string = parse_url($url, PHP_URL_QUERY);
    parse_str($url_string, $id);
    if (isset($id['v'])) {
        return '<iframe width="100%" height="100%" src="http://www.youtube.com/embed/'.$id['v'].'?rel=0&theme=light&showinfo=0&iv_load_policy=3&vq=hd720" frameborder="0" allowfullscreen></iframe>';
    }
    return $html;
}
add_filter('oembed_result','Oembed_youtube_no_title',10,3);

function alx_embed_html( $html ) {
    return '<div class="video-frame">' . $html . '</div>';
}
add_filter( 'embed_oembed_html', 'alx_embed_html', 10, 3 );
add_filter( 'video_embed_html', 'alx_embed_html' ); // Jetpack

function add_oembed_soundcloud(){
wp_oembed_add_provider( 'http://soundcloud.com/*', 'http://soundcloud.com/oembed' );
}
add_action('init','add_oembed_soundcloud');

Nasgor on "Custom Post Archive Loop"

$
0
0

Hi, I'm creating a plugin to display Custom Posts in a Web. Almost everything works fine, but I would need to show the archive in alphabetical order and excluded Child Pages from the loop. Don't know if there is any function that allows me to modify the query. Any tips?
Thank you very much.


pixel016 on "How to update image"

$
0
0

Hi everybody,

I have a custom field "upload image" on the user profile page.
When the user upload an image, it appear on the wordpress media library and on a featured image on a custom post.

So the first upload is ok, the image update is ok but when we do the update when there is no new image it removes the old image. (sorry for my english).

I use this code

$thumbnail_id = get_post_thumbnail_id( $post_id );

            if ($thumbnail_id == "") {
                  $attach_id = wp_insert_attachment( $attachment, WP_CONTENT_DIR . '/uploads' . $filename, $post_id);
                  require_once( ABSPATH . 'wp-admin/includes/image.php' );
                  $attach_data = wp_generate_attachment_metadata( $attach_id, WP_CONTENT_DIR . '/uploads' . $filename );
                  wp_update_attachment_metadata( $attach_id, $attach_data );
                  set_post_thumbnail( $post_id, $attach_id );
            }
            else {
                  $attach_id = wp_insert_attachment( $attachment, WP_CONTENT_DIR . '/uploads' . $filename, $post_id);
                  require_once( ABSPATH . 'wp-admin/includes/image.php' );
                  $attach_data = wp_generate_attachment_metadata( $attach_id, WP_CONTENT_DIR . '/uploads' . $filename );
                    wp_delete_attachment($thumbnail_id );
                    wp_update_attachment_metadata( $attach_id, $attach_data );
                    set_post_thumbnail( $post_id, $attach_id );

            }

newbutold47 on "pass data from a gallery page to a product"

$
0
0

I want to have a link on a product page that directs the user to a gallery of items from which to select the item they want. The selection is passed to the product page either as an image or a description and included in the cart.

Thank you

rekkette on "Assign Featured Image for Category"

$
0
0

Hi. I'm working on a child theme and I need to have a featured Image (thumbnail) representative of each category.

I found a plugin that will do this, but I have a structure I'm trying to work out and the shortcode on that plugin interferes with it - or I'd have to really modify the plugin to do what I want, that it just seems it would be easier to find a way to do it on my own.

Steven Strand on "Enqueue and use Boxer.jquery from Formstone"

$
0
0

Hi,

I am currently working on a one page portfolio and would like to implement the jquery slider "Boxer - Mobile" from Formstone (http://formstone.it/components/boxer).

But have problems with enqueueing the script and implement it in to the single.php.

My page is at the moment under construction... but see this homepage-design - http://www.formuswithlove.se/ for the full-screen solution which I am looking for.

loiste2 on "Override the Wordpress core function wp_referer_field"

$
0
0

I'd like to override the core Wordpress function wp_referer_field with folowing code:

function wp_referer_field( $echo = true ) {
$referer_field = '<input type="hidden" name="_my_wp_http_referer" value="'. urldecode(esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) )) . '" />';

if ( $echo )
    echo $referer_field;
return $referer_field;}

I've found that wp_referer_field is not pluggable and that I need to use some other technics for that. Adding some filters or actions. I was trying to use these code:

add_filter( 'wp_referer_field' , 'wp_referer_field_cyrillic' );
function wp_referer_field_cyrillic( $echo = true ) {
$referer_field = '<input type="hidden" name="_my_wp_http_referer" value="'. urldecode(esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) )) . '" />';

if ( $echo )
    echo $referer_field;
return $referer_field;}

But it doesn't work. It seems that I did something wrong.

Viewing all 8245 articles
Browse latest View live




Latest Images