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

oneruffryder on "How to add icon over thumb"

$
0
0

Hi all, i m not so good with php, but i wanted to do this, and i know its possible, but i dont know why. I m looking at http://codex.wordpress.org/Function_Reference/in_category but it doesnt make to much sense.

Basically what i want to do, for an example on my homepage, category page and similar post are shown with title and a thumb.

And for this thumbs i want to add function like this

if post/thumb is inside category video -> add video icon above it. I guess with css i would need to position it for an example at the bottom right corner.

Any ideas how to this


kikimarie123 on "Separate list into two even columns"

$
0
0

I have an unordered list (of team members) that I want to automatically separate into two columns - even when new team members are added. Is there a way to do this? Here is my code:

<div class="team-list">
<?php $args = array(
	'posts_per_page'  => -1,
	'post_type' => 'team-members',
	'meta_query' => array(
		array(
			'key' => 'team_member_category',
			'value' => '"Alphabetical Listing"',
			'compare' => 'LIKE'
		)
	)
);
$the_query = new WP_Query( $args ); ?>
<?php if( $the_query->have_posts() ): ?>
	<ul>
	<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
                <li>
		<a href="<?php the_permalink() ?>" title="<?php printf(__('%s','rys'), get_the_title()) ?>" rel="bookmark" ><?php the_title(); ?></a>
		</li>
	<?php endwhile; ?>
	</ul>
<?php endif; ?>
<?php wp_reset_query();  // Restore global post data stomped by the_post(). ?>

</div><!--end .team-list -->

Help please!! :)

Aaron Dicks on "Custom comment meta via filter - 'Trying to get property of non-object' error"

$
0
0

Hi Everyone
I'm trying to add in additional comment fields via the filter comment_form_after_fields, then save it via comment_post.

My two code snippets are below;

add_action( 'comment_form_logged_in_after', 'plugin_additional_fields' );
add_action( 'comment_form_after_fields', 'plugin_additional_fields' );

function plugin_additional_fields() {
	echo '<p class="comment-form-cost">'.
	'<label for="cost">' . __( 'Project cost' ) . '<span class="required">*</span></label>'.
	'<input id="cost" name="cost" type="text" size="30" tabindex="5" /></p>';
}
add_action( 'comment_post', 'plugin_save_comment_meta_data' );
function plugin_save_comment_meta_data( $comment_id ) {
	if ( ( isset( $_POST['cost'] ) ) && ( $_POST['cost'] != '') ) {
		$cost = wp_filter_nohtml_kses($_POST['cost']);
		add_comment_meta( $comment_id, 'cost', $cost );
	}
}

I've changed the function names for now, so ignore inconsistencies there if there are any.

This successfully renders the additional field in the comment box (although not with Jetpack :( )

If I submit a comment, it doesn't automatically appear below as I'd normally expect it to. When I check in the backend I see the two following issues;

Notice: Trying to get property of non-object in /home/sites/DOMAIN.co.uk/public_html/wp-includes/capabilities.php on line 1180
Notice: Trying to get property of non-object in /home/sites/DOMAIN.co.uk/public_html/wp-admin/includes/class-wp-comments-list-table.php on line 484

The line numbers differ (there are perhaps 20 errors in total).

I've disabled all plugins and removed all custom functions.php file contents, so I think it's down to my script above. The issue only persists when I've got a comment in the pending queue - so it must be an issue of reading in the custom meta?

Any help would be appreciated!

Aaron

Stefan83 on "Migrate cakephp script to Wordpress"

$
0
0

Hi

I'm trying to migrate this script to a wordpress template page but it breaks the page and nothing loads from where the script starts. I believe I need to remove the CakePHP controller. I've not really used cakephp and I'm not sure if this is the correct place to post but thought someone may have experience migrating cakephp scripts to wordpress. If anyone can help me convert this to a standalone php script/wp plugin that would be very helpful

http://pastebin.com/1ST44Zci

Thanks
Stefan

megamonster912 on "Ignore post instead of creating slug."

$
0
0

I've been playing around with the post.php file changing slug format for posts with identical titles. But I really want wordpress to refuse the post entry into the DB if the title is already used. Is there a simple way to do this?
I tried the return; instead of suffix but that only resulted in creating a new post using the same slug. If the title is already being used I don't want it in my db again nor do I want a slug added to it.

mrwjr on "unregister_setting bug?"

$
0
0

Hi all,

I wanted to run this by the forums before anything. There's a possible bug in the unregister_setting() function on line 1668 in wp-admin/includes/plugin.php
I'm experiencing this with Wordpress 3.6 running PHP 5.4.4

I'm using the Settings API to register two text input fields in the plugin I'm writing. I'm using register_setting() to register it with Wordpress like so:

register_setting( 'plugin_settings', 'plugin_settings');

Note the option_name and option_group are the same. I left out the sanitation callback because it's not relevant to the bug.

In my deactivation hook, I'd like to use unregister_setting() to unregister the setting when the plugin gets deactivated (duh). I'm doing this like so:

unregister_setting( 'plugin_settings', 'plugin_settings');

However, this isn't working; the setting stays set even after calling the function. I looked through the core at the unregister_setting() function on line 1655 in wp-admin/includes/plugin.php

It's my understanding that when you use register_setting() your setting gets added to the global $new_whitelist_options and unregister_setting() is supposed to remove it from this. The function looks for the position of the setting in $new_whitelist_options using PHP's array_search.

$pos = array_search( $option_name, (array) $new_whitelist_options);

This is constantly coming up false because array_search is only made for single dimension arrays, while $new_whitelist_options is multidimensional. Dumping the variable gives me:

array('plugin_settings' => array( 0 => 'plugin_settings'))

The search is failing because the option it's trying to unregister is one level deeper than array_search looks for.

I'm pretty sure I'm using these functions correctly, but I wanted to make sure that I wasn't missing anything. I can confirm my above suspicion because changing line 1668 to:

$pos = array_search( $option_name, (array) $new_whitelist_options[$option_group] );

finds the correct position of the element and removes it from the global whitelist.

Any thoughts?

kitcorsa on "Direct Required - Flooring Site - E-commerce/booking"

$
0
0

Im looking for a bit of advice or direction here,

Im looking to make a site for my brother who is specialist flooring expert who can supply fit and repair floors. What i'm after doing is creating a restoration site for him which explains how he resorted and repairs old wood floors and preserves them. this part is straight forward enough etc, the wall i'm hitting and getting stuck on is an online quote / booking system which could have a payment (paypal option)

This service is fairly straight forward as my brother charges a set price per square meter, so what i'm trying to do is create a form where the customer can enter the width and length of there room, and get a quote, then send a booking email to my brother with the same information for my brother to contact them and arrange the appointment to go round, inspect and perform the job.

The next problem is what if the customer has more than one room?? is there a way of adding a room 2 room 3 etc etc etc if required.

We have also though about taking an online deposit via paypal for say 10%, we would not be able to take the full amount as the customer may enter the wrong size trying to get a cheaper job done, or over changed by not measuring correctly. Deposit first and final payment on completion would be better if possible.

Could anyone please point me in the right direction please. Thank you

SpikeTheLobster on "Database Create View"

$
0
0

I'd like to create a new view in my database but I can't seem to do it actively, through a php function. I can't find any info on doing this, though there's plenty on making tables. The only support thread I saw on it was a year old and had no responses.

I've tried using the table creation functionality ($sql = "blahblah", require_once the upgrade.php file and dbDelta($sql)), but that doesn't achieve anything.

I even tried running the view creation SQL as a query using get_results($sql) but that didn't work.

Is it possible to create a view via a function and, if so, how does one go about it? I can do it through phpMyAdmin if I have to, but I'd really rather do it dynamically so that it handles itself as part of my custom theme.

Thanks in advance.


winglessalex on "Gallery by Category"

$
0
0

Hey all,

I'm setting up a site for photoblogging, and I want a gallery page of all the images from my image posts, with the gallery automatically updating every time I add a new image post.
I'm adding all my frontpage image posts to a category called "photos" and want all those images to show up on the one page.
I've added a shortcode to my functions, but its not working.

Here is my function.

add_shortcode('catgallery', 'wpse_70989_cat_gallery_shortcode');

function wpse_70989_cat_gallery_shortcode($atts)
{

    $arr = array();
    $cat_in = explode( ',', $atts['cat'] ); //get category by ID
    $catposts = new WP_Query( array(
        'posts_per_page'    => -1
    ,   'category__in'      => $cat_in
    ) );

    foreach( $catposts->posts as $post) //get posts from category
    {
        $args = array(
            'post_type'     => 'attachment'
        ,   'numberposts'   => -1
        ,   'post_status'   => null
        ,   'post_parent'   => $post->ID
        );
        $attachments = get_posts($args); //should get attachment info from posts
        if ($attachments)  //array seems to be empty at this point
        {
            foreach ( $attachments as $attachment )
            {

                $arr[] = $attachment->ID;

            }
        }

    }
    $return = do_shortcode( '[gallery include="' . implode( ',', $arr ) . '"]' );
   //outputs [gallery include=""] into site
    return $return;
}

Basically, this searches for the category ID, gets the posts in that category and should lookup attachments on those post to add to the [gallery include=""] shortcode.

I've narrowed down the problem to the attachments,
the function is getting all the posts from my 'photos' category, but it is not getting the attachment information from the posts.

I'm not an expert on php coding, so if anyone can help me out and let me know where I went wrong, or a better way to do this, I'd greatly appreciate it.

samhamilton81 on "media_handle_sideload has no file extension"

$
0
0

Hi guys,

I'm using the media_handle_sideload example code from the codex

http://codex.wordpress.org/Function_Reference/media_handle_sideload

It all works fine except for the fact that the image added to the media library has no file extension (.jpg), so it doesn't display.

If I visit the extensionless file by the URL I can download it to my desktop and rename it with .jpg and open it, so I know the file itself is fine. It just has no extension.

Any suggestions?

robinpen on "Hidden embeded third party a href tags"

$
0
0

Hi.. My site recently had an link added from a third party GLOBloans.com. It is showing on all my menu pages. When I tried to edit an indivual page the a href is not showing it seems to be invisible to Wordpress. I can't find where it has attached itself. Couldn't find it on the CSS file, or index.php, and am not sure how review the SCL database. Has anyone else had this problem? If I have the exact a href code how can I search or located in WP?
Thanks for your help

intelligencecompany on "Product database"

$
0
0

Hello there,

I am going to write a product database for our phone site. We already have our tables and the fields. Actually, we just can start entering a product into the database. My question is --- I really do not have an idea --- how can I display them publicly?

First: I would like the call each product through a slug, not like this: http://mysite.com/products/id=123456. I rather want this: http://mysite.com/products/nokia-lumia-925 or http://mysite.com/products/apple-iphone-5

So. How do I display them and how can I WordPress tell, that this URL referers to product XYZ?

These are my questions for the start. Thank you guys!
intelligencecompany

kevmatic on "Swap thumbnail for full on hover"

$
0
0

I'm trying to write a script that changes the banner src when you hover over a thumbnail. In my theme I've got two custom image sizes a 90x90 thumbnail & a banner image size which could be 9999x230. I thought I could manipulate via jquery the image src of the banner by removing the 90x90 in the src attribute. This worked, however it is generating the full size image instead of the custom image size with the possible 9999 width x 230 height. Any suggestions on how I could go about pulling in that correctly sized banner image?

ErEduEr on "How do it"

$
0
0

Hi, i'm from spain so sorry for my inglish.

I'm coding a plugin and i want that if you enter a estatic page ex: http://www.myweb.com/estaticpage/

my plugin enter in action... not in all estatic pages, only in one that i select.

I dont know if you underestand me....

Thanks!!

Kry8ter on "Excluding by Tag String, Register by Function?"

$
0
0

I have 3 loops running on the front page.

One for the slider, and it wants posts that have the tag "slider".

One for featured articles, and it wants posts that have the tag "featured".

And a third I am calling in loop_latest.php, it wants the 6 latest posts; the trick here is those need to be the 6 latests that do NOT have the tags "slider" or "featured".

So I have this query.

$query = new WP_Query(
     array(
              'showposts' => '6',
              'tag_not_in' => array('featured, slider'),
     ) );

I'm pretty sure the problem here is that "tag_not_in" doesn't like strings, it wants IDs.

SO! Is there a way to pass it the strings?

If not, how do I divine what the IDs of tags are?

Can I run some code in "functions.php" to set and reserve the ids? featured == 777, slider == 888
Something like that?

I'd like to be able to SET them so that gets packaged with this theme. Rather than have to hope that when the client registers the tags "slider" and "featured" they match up with what I have chosen in the loops/query.

Thanks for your help, my google-fu isn't working out on this one.


Sirio Alieghieri on "Add new tab next to Visual and Html in wordpress text editor?"

$
0
0

I would like to know if there is any way to create get new tab associated metabox for wordpress editor like visual/html tab, for example the "Coconut" tab you can see in the image below.

Do you have any ideas?

Example

ZainB on "Custom Icon for Custom Mime Type (Media Uploader)"

$
0
0

Hi,

I've just added a new mime type to support the upload of a new image type using the Media Uploader. I've got my image type uploading nicely... however, I'm wondering if anyone has any tips on how to add a custom icon for the new mime type?

This is a similar issue to the one found in this forum post:
http://wordpress.org/support/topic/custom-icons-in-media-manager-for-custom-mime-types?replies=6
However, the link to the resource is no longer available.

It would be great to be able to show a specific icon in the Media uploader, for any new image types - at the moment, nothing appears. Displaying an icon (instead of a broken image) on the page, would also be useful.

Finally, any ideas or suggestions on how to access the "attachment display settings", so that the image dimensions for the image file/icon can be set? (As you would for a JPG, GIF or PNG file in the Media Uploader, when selecting an image to attach to a post).

Thanks in advance for any links, tips, tricks or suggestions!

Nerina-01 on "previous_posts_link not showing on page 2 while next_posts_link is."

$
0
0

I have a Static page set as front_page and I use a WP_Query the page template includes to display posts. I have a template part product-list.php and in it I have the following:

$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$query = new WP_Query( array( 'paged' => $paged ) );
	$products_args = array (
		'post_type' => 'bb_product',
		'posts_per_page' => 3,
		'paged' => $paged
	);

And then after the $products_query loop:

<?php if ( $products_query->max_num_pages > 1 ) : ?>
    <div class="navigation">
        <?php
        // Bring $wp_query into the scope of the function
        global $wp_query;
        // Backup the original property value
        $backup_page_total = $wp_query->max_num_pages;
        // Copy the custom query property to the $wp_query object
        $wp_query->max_num_pages = $products_query->max_num_pages;
        ?>
        <div class="alignright"><?php next_posts_link('Next Entries'); ?></div>
        <div class="alignleft"><?php previous_posts_link('Previous Entries'); ?></div>
        <?php
        // Finally restore the $wp_query property to it's original value
        $wp_query->max_num_pages = $backup_page_total;
        ?>
    </div>
<?php endif; ?>

The problem is that when I am on page 1, I can see the next_posts_link, but when I am on page 2 there is still only the next_posts_link and no previous_posts_link (the HTML markup is there, but the link is missing). Even when I'm on the last page, there is only the next_posts_link (although there are no next posts) and no previous_posts_link.

I've read many threads with similar/same problems, but I can't solve it. This post helped me to show the navigation at all, before both links where missing.

My test site is here, to see it scroll down, the pagination has a red background.

Can somebody help or point me in the right direction?

Thank you.

eleytheria on "sharing bug"

$
0
0

Hi. Every time I try to share a post on Facebook, the thumbnails are of sportscars accompanied by foreign characters. People who've tried to access my site with android phones say they can't even get in as a big malware message appears, but I can access my site from my mac. It's the sharing that's a problem. When you click on the weird images, it does still take you to my site, but it seems that access is only available to mac users and sharing seems to have been hacked. I'm not a techie, so I can't deal with coding jargon. Any simple solutions out there?

WordBuddyPress on "No refer links"

Viewing all 8245 articles
Browse latest View live




Latest Images