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

roelof on "Can this be done with wp_archive_get"


Umbercode on "Custom infinite scroll and archives/search"

$
0
0

I have a file (loop.php) which contains the loop (while (have_posts ... endwhile)
Next I have an index.php, archive.php and a search.php. All of which contain get_template_part('loop').

In my functions.php I add a hook called wp_ajax_infinitescroll which executes the following function:

function MyInfiniteScroll(){
   $loop        = $_POST['loop'];
   $page           = $_POST['page'];
   query_posts(array('paged' => $page ));
   get_template_part($loop);
   exit();
}

Then I have some JavaScript which does (I left out some code here to simplify):

jQuery.ajax({
    url: "http://xxxxxxxxx/wp-admin/admin-ajax.php",
    type:'POST',
    data: "action=infinitescroll&page="+ pagenr + '&loop=loop',
    success: function(html){
        jQuery("#gids").append(html);
    }
});

My problem: on index.php this works perfectly, it shows all posts.
On both archive.php and search.php the first "page" works also, but any subsequent "pages" load all the posts again and not those limited to the search or archive.
I suppose somewhere along the line WP_Query is "reset"? So what am I doing wrong here/am I forgetting?

PS: before someone tells me there is an infinite-scroll plugin, I know. However it is not usable in this particular case which is why I try to write my own.

senyoraangelica on "Cant get php to work inside shortcode content"

$
0
0

I tried several solutions from looking at similar questions within the site but it won't work me. =( Please help.

This is an excerpt from my original code:

<form action="" method="get">
<input type="text" name="search" value="">
<input type="submit" value="Search">
<?php echo do_shortcode('[expand]
<input type="checkbox" name="title" <?php if(isset($_GET['title'])) echo "checked='checked'"; ?>>
    <label for="ti">Title</label></td>
[/expand]'); ?>
</form>

Basically, I want my checkboxes to remain checked, if they were checked before hitting submit. Unfortunately, it's been hours and I can't get the php to work inside the shortcode.

Please help.

dearlydemented on "Shortcodes for recent posts"

$
0
0

Hi, all help is appreciated!

I'm struggling to set up my "home" page. I only want to display the 4 recent posts of each category there.
This shortcode works fine:

[home_posts heading='Reviews' posts_per_page='4'][/home_posts]

But I'd like to display only one category and one only there. Is that possible?

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.

trecoolz on "Plugin if statement not working"

$
0
0

Hello all

I'm developing a simple plugin to show some social icons based on options. I have used if statements successfully before now with no issue. The following code is causing me problems:

<?php if ( get_option('sd_facebook_visible') ) {
					echo '<li><a href="' . get_option('sd_facebook') .  $linkcontent['facebook'] . '</a></li>';
				} ?>

I have done var_dump(get_option('sd_facebook_visible')); which returns the following.

string(1) "1"

It is a checkbox on my options page. No matter what state the checkbox is it just wont show any ideas?

Many Thanks

mstrdh on "[WooCommerce 1.6.5.2] Add custom fee in Shopping Cart"

$
0
0

Hi! I had a difficult task, so I need your help, guys.
I need some fixes in shopping cart.
1. If a customer buys less product that costs less than 1000kr, then 200kr needs to be added to the price. The 200kr should be added as a new product in the checkout. So.. if you buy one product, the checkout should be:
U-stång: 168kr,
Starting cost: 200kr,
Pic 1
Pic 2
http://metalldirekt.se/produkt/u-stang-3/
Best regards!

norrist on "Delete rss feed"

$
0
0

I discovered that I have two rss feeds. One that ends in /?feed=podcast and the other ends in /?feed=rss2. I want that one that ends in /?feed=rss2 deleted. I found it by doing a simple google search. I have it selected on my site for it not to be searchable by search engines. How do I delete the rss2 feed and not the other

I've searched the forums and tried some other steps, but it always deletes both feeds and not the one. HELP! :)


kuckovic on "Search price range"

$
0
0

Hi all!

I'm using the theme Realtr from Templatic.
I'm making an estate site, and I wanted to know if anyone could help me - here's my problem:

Problem:

In the right sidebar, I have a pricerange option, called "Pris Niveau" - it works fine as it is, but it has to many options.

My vision:

Instead of one drop-down with 30 options, I would like to have 2 textfields, so that the customers can enter the minimum and maximum pricerange - I just can't make it work! Can you guys help me? please!

Code-snippet

<label><?php echo SEARCH_PRICE_RANGE_TEXT; ?> : </label>
          <select name="srch_price" id="srch_price" onchange="" class="fl select">
            <option value=""><?php echo SELECT_ALL_PRICE_TEXT; ?> <?php _e("in","templatic");?> <?php echo get_currency_sym();?> </option>
            <?php echo get_price_range_dl($_REQUEST['srch_price']);?>
          </select>

Please!
I really nees your help...

gerard749 on "add date, function.php"

$
0
0

Hi,
I put the following code in my child themes function.php file:

add_filter('widget_text', 'do_shortcode');

function displaydate(){
return date('l, F jS, Y');
}
add_shortcode('date', 'displaydate');

[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.]

In the General Settings when I set the timezone to New York (correct time) or UTC-4, at 8pm the date changes to the following day.
Any help would be appreciates.
Thank You,
Jerry

WordPress 3.6
Thematic Theme 1.0.4

TheXero on "Setting the Secure flag on cookie wordpress_logged_in"

$
0
0

Hey

I know this affects version 3.x as well, but this has bugged me for a while.

On an SSL wordpress blog, even using the 'SSL Wordpress' plugin, the secure flag is not set on the wordpress_logged_in cookie.

To set it on cookies, change the file at wp-includes/pluggable.php

setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, COOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
setcookie(LOGGED_IN_COOKIE, $logged_in_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true)

Where it says '$secure_logged_in_cookie' change to '$secure' on both lines.

I think this will muck up sites which don't have SSL support.

Could this maybe be officially fixed in 3.6.1 or something?

Toby

Farlif on "Add "async" by script-loader.php"

$
0
0

Hi,

loading times become more important every day. Therefore I'd like to load the jQuery.js in the header with an "async"-tag. The registration of the jQuery is done by wp-include/script-loader.php:

// jQuery
	$scripts->add( 'jquery', false, array( 'jquery-core', 'jquery-migrate' ), '1.10.2' );
	$scripts->add( 'jquery-core', '/wp-includes/js/jquery/jquery.js', array(), '1.10.2' );

Now, I am not so skilled in writing php, and I don't know where and how to tell the script to load jQuery with "async". Any hints for me?

Cheers,
Stefan

pstanev on "How to add user page with my plugin"

Matt McFarland on "how to auto rotate iPhone image upon upload using functions.php?"

$
0
0

Hi all,

I've been struggling for the past 2 weeks trying to figure out how to do this. I run a community based site for a client where people upload images and the images are then posted to the blog. My client wants the iPhone pics their users upload to automatically be rotated (like facebook does, and other sites)

I would like to hook into attachment function(?) and rotate. I would like to use something like this(http://rtcamp.com/tutorials/fixing-image-orientation-wordpress-uploads/) without downloading a plugin.

I've tried rtMedia, and unfortunately it does not work at all(wont process or upload any pics, it appears broken), and other plugins that rotate images but nothing seems to work.

Honestly don't want a plugin with all the bloat anyway. I just need to hook into attachment_upload and run a script similar to what was linked above. I just don't understand how. My problem is, not sure which hook to use (which one is before upload? also is there any conflict with wp exif processing?)

Sorry for the long post Please share your thoughts.. Using wp 3.6.

TL;DR: how to grab iPhone exif data and fix image orientation? preferably creating a hook in functions.php to do it. dont want bloated plugin, should be just a function, cant find a way to do it, help.

Thanks,
Matt

nathangoldstein on "Custom Image Size Patch 3.6 Update"

$
0
0

Hi there,

Recently working with wordpress 3.5, I came across this patch :http://core.trac.wordpress.org/ticket/19889

...which solved the problem of custom image sizes defined by my theme not resizing or rotating properly. The issue was image-edit.php did not account for sizes added by the function add_image_size (i think this is the name of the function but not 100% sure) in functions.php.

this patch worked perfectly but unfortunately it does not work on 3.6. image-edit.php seems to have been replaced completely by different files and functions.
I could backup to 3.5 but the best thing to do is fix it under 3.6! I am not an experienced coder so I wanted to ask someone to have a look at the patch and help me go about fixing the .php file now responsible for editing images.

Thank you very much and it is somewhat urgent!

Nathan


nicnack on "adding variable/array to script"

$
0
0

Hi!

Below is a script that creates a widget area. Any widget that is added into this area is contained within a simple <div></div> tag.

I need the script to generate a unique ID per div (widget) created.. so that it would be like:
<div id="name1">widget 1 here</div>
<div id="name2">next widget here</div>
<div id="name1">another widget here</div>
etc..

here is the script:

function arphabet_widgets_init() {

register_sidebar( array(
'name' => 'Home Footer',
'id' => 'home_bottom_1',
'before_widget' => '<div>',
'after_widget' => '</div>',
'before_title' => '<h2 class="rounded">',
'after_title' => '</h2>',
) );
}
add_action( 'widgets_init', 'arphabet_widgets_init' );

any suggestions?
thanks!!

zhulongzheng on "load-{$page} action not work,other actions only work on post-new.php"

$
0
0

In my plugin, I want to do some operation on both post-new.php page and post.php page,or another way of saying when I add a new post and edit a existed post.
So I use the

add_action('load-post.php','my_test_funtion');//I hope this can work ,but it doesn't
add_action('load-post-new.php','my_test_funtion');//I hope this can work ,but it doesn't
add_action('wp_insert_post','my_test_funtion');//This is the original code,but it only works on the post-new.php,and I can't find a similar action on the post.php page

in my plugin.

And then I try to use

add_action('admin_enqueue_scripts','my_test_funtion');//only for test
add_action('admin_print_styles','my_test_funtion');//only for test
add_action('admin_print_scripts','my_test_funtion');//only for test
add_action('admin_head','my_test_funtion');//only for test

but all above do not work on all admin page but the post-new.php, and I can't see any effect but on the post-new.php. So weird!

I hope you guys can help me , it's so confusing!

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!

jeffersonpowers on "Add post tag name to single post body class"

$
0
0

I am searching for a way to add each post's tag to its single post body class. I specifically need the tag name to appear as a body class (an article class or anything farther in won't help).

Is there a simple bit of code I can add to my theme functions that will do this?

I'm running WordPress 3.6 and using a child theme of TwentyTwelve with minimal changes to the theme.

I would greatly appreciate any help. Thanks!

webwerk on "[Plugin: WordPress-to-lead for Salesforce CRM] Additional form field types?"

Viewing all 8245 articles
Browse latest View live


Latest Images