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

PhPCentre on "Watermark without plugins"

$
0
0

Use the wp_generate_attachment_metadata filter. It fires after creating thumbnails.


Dave Navarro, Jr. on "Problem with WP-CRON Event"

$
0
0

I have disabled WP-CRON in my WP-CONFIG. And then I added an CRON event on my web server that executes WP-CRON every 5 minutes. That's been working great for years now.

I have a newsletter plugin I wrote that emails a newsletter every weekday morning at 7am.

However, since upgrading to 4.1 every once and a while (once or twice a week) the WP-CRON event for my newsletter fires 2 or 3 times and so 2 or 3 emails are sent out for each user.

What I need is some kind of semaphore or something that will let me check to see if the event is in process and abort so that it's only executed once and not multiple times simultaneously.

Thanks for any suggestions you can offer.

Free269 on "adding separator"

$
0
0

Hi,

I'm working on a new theme based on the twentyfourteen theme.
I want to add some dot separators on the main navigation menu.
So I rewrote this line in the head:
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu', 'link_after' => '</a> ·' ) ); ?>

the problem is that it adds a dot on the last loop
Ex:
Home - About - Info - Cars - Buses -

Any ideas how to solve this?

timarsen on "Sorting search results by custom fields"

$
0
0

I want search results to be able to be filtered by custom fields after someone has searched for a keyword. So if someone searches for posts of restaurants they can then change the order of the results to be sorted by
"Rating" or "Price"/. I've added a dropdown menu with options how can I make it resort the search results?

urban365 on "How do I use a "PHP Function" to return an "Array value" ?"

$
0
0

I am trying to return posts from a post type called "single_release_post" that has a meta tag of "u365_artist_name". I got that to work, but I want to take it a step further and choose what that "u365-artist-name" actually returns based off which page you're on.

MY PROBLEM is that I want to make the value in the array (shown below) my currently viewing post title if that makes sense... lol. So for example if the post title of the page your viewing is "Jon Banks" the array value of "u365-artist-name" would be "Jon Banks". Therefore it would return the posts from what artist name I type in my meta box from my post type "single_release_post".

<?php
								// Single Release Posts
									$args = array (
									'post_type'              => 'single_release_post',
									'post_status'            => 'publish',
									'pagination'             => false,
									'posts_per_page'         => '3',
									'posts_per_archive_page' => '7',
									'ignore_sticky_posts'    => true,
									'key'      				 => 'u365_artist_name',
									'meta_query'             => array(
										array(
										'value'     => '',
										'compare'   => '=',
										'type'      => 'CHAR',
											),
											),
											);
								// The Query
									$single_release_artist_single = new WP_Query( $args );
								// The Loop
									if ( $single_release_artist_single->have_posts() ) {
									while ( $single_release_artist_single->have_posts() ) {
									$single_release_artist_single->the_post();
							?>

The above code is what I have so far on a page i'm working on here http://e9f.78a.myftpupload.com/artist/jon-banks/ As you can see the "Take Off" post should not be showing because it has a artist name of "GA" and your viewing the "Jon Banks" page.

Does anyone know how I can return the "u365

deprekate on "Display progress of an ajax call"

$
0
0

I have a button that when clicked, performs two system calls using ajax. Is there a way to update a textbox with the current progress (i.e. "Task 1 finished. Task 2 pending")?

All I can figure out is to return when both tasks are finished.

I was thinking I could do two $.post(ajaxurl, data, function (response){ calls inside my $( ).click(){ but it doesn't work.

I am using the sample plugin ajax-wordpress-boilerplate.

gokberkozcicek on "Delete child categories functions"

$
0
0

I needed a function can delete childcategories. But I did not found. Than I wrote a simple function. If you need, you can use this function to delete sub categories of a category.

function go_delete_child_categories($parent_cat_id){

	$args = array(
		'type'                     => 'post',
		'child_of'                 => 0,
		'parent'                   => $parent_cat_id,
		'orderby'                  => 'name',
		'order'                    => 'ASC',
		'hide_empty'               => 0,
		'hierarchical'             => 1,
		'exclude'                  => '',
		'include'                  => '',
		'number'                   => '',
		'taxonomy'                 => 'category',
		'pad_counts'               => false

	);

	$children=get_categories($args);

	foreach($children as $child)
		{
		wp_delete_category($child->cat_ID);
		}
	}

Usage:
-Sample Category (ID=1)
--Child1
--Child2

go_delete_child_categories(1);

Function delete child1 and child2

jahed on "Changing $failed_login_limit and $lockout_duration value from wp setting api"

$
0
0
if ( ! class_exists( 'Jeba_Limit_Login_Attempts' ) ) {
    class Jeba_Limit_Login_Attempts {

        var $failed_login_limit = "3";                    //Number of authentification accepted
        var $lockout_duration   = "1800";                 //Stop authentification process for 30 minutes: 60*30 = 1800
        var $transient_name     = 'attempted_login';    //Transient used

        public function __construct() {
            add_filter( 'authenticate', array( $this, 'check_attempted_login' ), 30, 3 );
            add_action( 'wp_login_failed', array( $this, 'login_failed' ), 10, 1 );
        }
        public function check_attempted_login( $user, $username, $password ) {
            if ( get_transient( $this->transient_name ) ) {
                $datas = get_transient( $this->transient_name );

                if ( $datas['tried'] >= $this->failed_login_limit ) {
                    $until = get_option( '_transient_timeout_' . $this->transient_name );
                    $time = $this->when( $until );

                    //Display error message to the user when limit is reached
                    return new WP_Error( 'too_many_tried', sprintf( __( '<strong>ERROR</strong>: You have reached authentification limit, you will be able to try again in %1$s.' ) , $time ) );
                }
            }

            return $user;
        }
        public function login_failed( $username ) {
            if ( get_transient( $this->transient_name ) ) {
                $datas = get_transient( $this->transient_name );
                $datas['tried']++;

                if ( $datas['tried'] <= $this->failed_login_limit )
                    set_transient( $this->transient_name, $datas , $this->lockout_duration );
            } else {
                $datas = array(
                    'tried'     => 1
                );
                set_transient( $this->transient_name, $datas , $this->lockout_duration );
            }
        }

        private function when( $time ) {
            if ( ! $time )
                return;

            $right_now = time();

            $diff = abs( $right_now - $time );

            $second = 1;
            $minute = $second * 60;
            $hour = $minute * 60;
            $day = $hour * 24;

            if ( $diff < $minute )
                return floor( $diff / $second ) . ' secondes';

            if ( $diff < $minute * 2 )
                return "about 1 minute ago";

            if ( $diff < $hour )
                return floor( $diff / $minute ) . ' minutes';

            if ( $diff < $hour * 2 )
                return 'about 1 hour';

            return floor( $diff / $hour ) . ' hours';
        }
    }
}
new Jeba_Limit_Login_Attempts();

Unsal Korkmaz on "What will happened to Post Formats?"

Paljasporgand123 on "Unlimited number of posts for category page"

$
0
0

Hi,

I am quite new to WordPress and not the best hacker. I want to make my category page show unlimited number of posts instead of the default 10 posts. I have read a lot of forums, that recommend editing The Loop. I cannot even find anything like that in the The Foodie Pro Theme. Can someone please help me out?

My page is http://www.paljasporgand.ee

The categories page I want to edit is KEHA&VAIM. I do not want to see "the next page" down there. I want all the posts to be listed.

Thanks!

Vykerus on "Search widget float over slider"

Looic on "New admin action for custom post types"

$
0
0

Hi All,

I manage a product database with a custom post type. I added new columns to the admin panel with manage_posts_column filter.

Now, on one of these columns, I would like to add a specific admin action, for example : Sent by Email. When the Sent by Email link is hit within the admin panel, the plugin I work on is reloaded with this action.

How could I do that ?

Thank you for your help,
Looic.

sendz on "Duplicate Comments Screen on a Plugin"

$
0
0

Hi,

I am developing a plugin that need list all comments on its dashboard from a specific post / page with exactly same view with the "Comments".

For example, I have post with ID 17 and I need to show all comments of ID 17 on Plugin admin page.

Is it possible?

Thanks.

ebiz212 on "display post for logged in user only"

$
0
0

HI

Im trying to make what seems like a simple adjustment to a plugin im using, unfortunately im just a 'wannabe programmer' and not the real deal so i wa shoping someone whom is a real programmer can help me out here. If you can help me i would be foreever grateful and even willing to pay a bit for someone to explain this process to me...... here goes:

Im working with a plugin, it has a list of posts recently created and shows ALL posts no matter which user i login with... I would like to change this to show ONLY post by the user whom is logged in... Below si the current code

<?php
global $wpdb;
$current_time = current_time('mysql') + 60;

$ereminder_array = $wpdb->get_results( $wpdb->prepare("
SELECT *
FROM {$wpdb->posts}

WHERE post_date <= %s

AND post_type ='ereminder'
AND post_status = 'draft'
AND author = 'wp_current_user'
ORDER BY post_date ASC
", $current_time) );
$scheduled_data = array(
'list' => $ereminder_array,
'type' => 'scheduled'
);
echo PDER_Utils::get_view( 'ereminder-list.php', $scheduled_data );
?>

if anybody can tell me how to alter above code to show only post by the user that is logged in instead of all the users like it does now i would be forever grateful.

thanks in advance

JudyHunter on "pdf to excel converter download"


Vann Digital Networks on "301 Redirect From Custom Post Types To Posts!!!"

$
0
0

I just converted custom post types to posts but I don't know how to go about setting the 301 redirect for the permalink structure.

Any help with this issue will be appreciated.

Liv on "Change title tag with custom fields for pages, posts and woocommerce products."

$
0
0

Hi,

I'd like to be able to change the title tag individually for pages, posts, category pages and products (woocommerce) by using a custom field.

Is there anyone that knows how to accomplish this without a SEO plugin?

Cheers!

Liv

realgigex on "Access individual price of each product in cart_contents"

$
0
0

I need to access the individual price of each product in my cart.
I already got the cart_contents using WC()->cart->cart_contents
and i manage to iterate over each one and access its properties, but i cant find the price anywhere.
I'm reffering to the WooCommerce product and cart objects if it wasn't clear.

jeriksson on "Remove Tags From Being Displayed in get_the_tags function"

$
0
0

Is there any simple filter that i could add to my functions that would exclude certain tags from being displayed when calling get_the_tags?

Thanks!

georgesjeandenis on "The Add Media button loads forever with my plugin (add_action "shutdown")"

$
0
0

Since I created my plugin, I see that the "Add Media" button does not load at all. However, when I comment the "shutdown" action, it works.

I created a plugin, it's basically just two custom post types with a few abilities added to them (http://lespointscom.com/a/misc/tcaan/tcaan_members.zip).

However, I noticed that the "shutdown" action, even without anything in it, creates a BUG :
add_action("shutdown", "tcaan_members_debug");

I made sure to empty the "tcaan_members_debug" function like so :

`function tcaan_members_debug()
{
/*
if(!(isset($_GET["post"]) && isset($_GET["action"])))
{
global $TCAAN_Members;
if(get_option("tcaan_show_debug") == 1)
{
$TCAAN_Members->tcaan_debug();
}
else{}
}
*/
}
`

Still, the bug persisted with the same "infinite" loading.
It was only when I decided to comment the add_action itself, that I noticed everything was working fine :

//add_action("shutdown", "tcaan_members_debug");

That seems to mean that "shutdown" does not work at all for wordpress 4.1.1 at least.

Viewing all 8245 articles
Browse latest View live




Latest Images