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

einwang on "Modify how a PDF file from the media library is displayed"

$
0
0

Hi everyone,

is it possible to modify the code that is generated when a PDF file from the media library is inserted into the editor?

Normally, it generates something like this:

<p><a href="link-to-pdf.pdf">Click here!</a></p>

What i want to do is to modify that generated code to make it look a little prettier. Maybe add a frame or a icon or stuff like that.

Would that be possible? If so, how can I do that?

I would appreciate your answers!

Greetings,

Chris.


Gnanasekaran Loganathan on "Bruteforce Attack"

$
0
0

Continusly getting Bruteforce Attack to my site.

I blocked all IP to hit wp-admin and wp-login page but even now also i getting Bruteforce Attack.

I installed scucuri plugin from this plugin i getting mail with the subject of site getting Bruteforce Attack
1. Changed user name in db
2. Added htaccess rule - no one can hit my wp-login.php and wp-admin
3. Changed wp-admin folder name

But even till now I get attack

iswinar on "AMP"

$
0
0

I use nginx to running my wordpress blog. How to make my site only show the AMP version on mobile device?

Main Sequence Technology, Inc. on "Removing anchor tag from shortcode input?"

$
0
0

I'm working on a simple plugin (my first) that converts a given shortcode with a URL as the input parameter into an iframe src. For example [Frame mylink="http://google.com"] This works perfectly, except…

If the user is working in TinyMCE's 'Visual' mode and copy/pastes the URL from an email into the editor, it often comes along with the <a> tag and turns into a clickable anchor rather than plain text. This breaks the shortcode. I can't even seem to get the parameter to pass through to my function at all if it's been wrapped with HTML.

Is there a way around this?

Fact Maven Corp. on "Group different tags in add_filter / add_action to the same function?"

$
0
0

Is it possible to group different tags in the add_filter or add_action to the same function? For example:

Instead of creating two add_filter to the same function (ex: same_function):

add_filter( 'script_loader_src', 'same_function' );
add_filter( 'style_loader_src', 'same_function' );

Have it turn out to be something like this:

add_filter( array( 'script_loader_src', 'style_loader_src' ), 'same_function' );

Fact Maven Corp. on "Redirect "wlwmanifest.xml" to homepage"

$
0
0

As a non-blogger, I do not use any of the blogging functionality that comes prebuilt on WordPress.

I've removed the wlwmanifest.xml from the header using the following action:

remove_action('wp_head', 'wlwmanifest_link');

However, this only hides the XML from my header. If I were to visit some.web/wp-includes/wlwmanifest.xml, the page still exists. I would like to create a function to disable and redirect that page to the main website should it be accessed. I figure the logic would go something like this:

add_action( 'template_redirect', 'redirect' );
function redirect() {
    if( is_page( '/wlwmanifest.xml' ) )
    {
        wp_redirect( home_url( '/' ) );
        exit();
    }
}

If I could get some guidance on this, I would appreciate it.

KennyLL on "WP 4.4 Responsive Images (srcset/sizes) in Text Widget"

$
0
0

I'm slowly wrapping my head around the new responsive images features in WP 4.4. I've got it fairly well figured out now for our CPTs & default page/post content images.

- But is there a way to have the new WP srcset & sizes attributes added to an image placed in a standard Text widget??

We could hard-code all of the extra data in the widget, but that would just be unwieldy to deal with and/or make updates to (there will be quite a few of them). Hoping there is a function or something that could replace a standard <img src="full-size-original.jpg"> with all of the srcset & sizes attributes as happens with images placed in content editor.

And ideally it might be nice to know how to modify the sizes attribute if needed. We were able to find something for post thumbnails, but not sure it would work here.

THANKS!

deuts on "Limit get_terms within a period"

$
0
0

I'm trying to use get_terms in order to display the top 10 terms in my custom taxonomy in the sidebar. However, I'm just wondering if there's any parameter I can use in order to limit the top 10 terms used in posts in a period, like for example in the last 30 days?


guylancaster on "gravatar"

$
0
0

Any one got a web link that can tell me how to programatically update the gravatar for a user from a screen and also recall and display it?

lukaszflorczak on "Custom rewrite rules for archive page and single post"

$
0
0

I'm building a WordPress site with several custom post types. Every post type is a different magazine. I have also a custom meta fields for a magazine year and issue.

I would like to have urls (used archive.php):

http://my_site/magazine/name/
http://my_site/magazine_name/year/
http://my_site/magazine_name/year/issue/

I made it by code:

function magazine_rewrite_tag() {
        add_rewrite_tag('%issue_year%', '([0-9]{4})');
	add_rewrite_tag('%issue%', '([0-9])');
}
add_action('init', 'magazine_rewrite_tag', 10, 0);

and:

function magazine_rewrite_rules() {
	add_rewrite_rule('^([a-z]+)/([0-9]{4})/([0-9])?', 'index.php?post_type=$matches[1]&issue_year=$matches[2]&issue=$matches[3]', 'top');
	add_rewrite_rule('^([a-z]+)/([0-9]{4})?', 'index.php?post_type=$matches[1]&issue_year=$matches[2]', 'top');
}
add_action('init', 'magazine_rewrite_rules');

Off course I have also a custom queries in archive.php. And it works fine.

But now, my urls for single articles doesn't work. By default, it is:

http://my_site/magazine/post-title

but it's show all articles from magazine like url (and it used archive.php template):

http://my_site/magazine/

How add properly rewrite rules for single custom posts? It is possible, I would like to have urls for single post (only for chosen custom post types) in this format:

http://my_site/magazine/year/issue/post-title

airsid on "User status 0 -1 1 2"

$
0
0

Hello,

I have almost 1350 users on my site so I have downloaded the user tab database from phpmyadmin to have look at it and see if everything look normal.
But some users have strange status: -1 or 1.
I know that 0 is activate and 2 is not. But what are -1 and 1 please ?

timb0jones on "Posts within page within page"

$
0
0

Hello there

Bit of a newbie but I was wondering if it was possible to display WHOLE pages that contain loops to show a certain post category, within a PAGE.

I've tried numerous plug ins but I'm not getting hugely far.

What I've managed to do is loop a page into a page, but then the orginal page does't execute it's own loop of pulling in the post content I want that to show...

Like inception, I know!

Any help would be amazing

Thank you

Tim

dronester on "Custom Menu Item Attributes"

$
0
0

Hi,
I need some help on creating a custom link to a dynamically changing url based off the user id.
What I am trying to do is create a menu item called "Profile" that links to the Author page. Because it is different for every user, it will be a dynamically changing url.
I know the way to link to the author page through php and html using this:
<a href="<?php the_author_posts_link(); ?>"</a>

So, how do I modify a menu item to link to this particualr tag?

Any help would be appreciated.
Thanks

sa_ostad on "How Do I Create Custom Capability for access to plugin page"

$
0
0

I want to create access control for my plugin,
some of yours just must access to specific page of my plugin.
I think this steps needed :

  1. create new role
  2. create new capability for specific page
  3. Assign capability to role
  4. Assign user to role

my problem is how can I create new capability to access specific page ?

Taanab on "Custom cookie deleted"

$
0
0

Hello There,
my plugin after activation set up some cookie for 10 years. any way how to save it, since after logout cookie deleted. Would you advice how to avoid that?


markross67 on "Help with the Meta function (functions.php)"

$
0
0

Hello,
Below is my meta function from my Twenty Twelve (Child) Theme.
I have it tweaked how I would like it to display my Post categories and Tags on the Archive pages of my blog site.

Example:
Posted in Opinion | Tagged Constitutional

I would, however, like to incorporate this bit of code:

<?php if ( comments_open() ) : ?>
				<div class="comments-link">
					<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
				</div><!-- .comments-link -->
			<?php endif; // comments_open() ?>

into the below code, if that is possible - so that the final result would appear like this:

Posted in Opinion | Tagged Constitutional | Leave a reply

Any help would be really appreciated!

Thank you,
Marc

/** Custom: Custom meta information */

if ( ! function_exists( 'twentytwelve_entry_meta' ) ) :
/**
 * Set up post entry meta.
 *
 * Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
 *
 *
 * @since Twenty Twelve 1.0
 */
function twentytwelve_entry_meta() {
	// Translators: used between list items, there is a space after the comma.
	$categories_list = get_the_category_list( __( ', ', 'twentytwelve' ) );

	// Translators: used between list items, there is a space after the comma.
	$tag_list = get_the_tag_list( '', __( ', ', 'twentytwelve' ) );

	$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
		esc_url( get_permalink() ),
		esc_attr( get_the_time() ),
		esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() )
	);

	$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
		esc_attr( sprintf( __( 'View all posts by %s', 'twentytwelve' ), get_the_author() ) ),
		get_the_author()
	);

	// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
	if ( $tag_list ) {
		$utility_text = __( 'Posted in %1$s | Tagged %2$s <span class="by-author"></span>', 'twentytwelve' );
	} elseif ( $categories_list ) {
		$utility_text = __( 'Posted in %1$s <span class="by-author"></span>', 'twentytwelve' );
	} else {
		$utility_text = __( 'Posted in %1$s | Tagged %2$s <span class="by-author"></span>', 'twentytwelve' );
	}

	printf(
		$utility_text,
		$categories_list,
		$tag_list,
		$date,
		$author
	);
}
endif;

isvictorious on "WP-API Multiple Custom Post Custom Fields"

$
0
0

Sorry if this is an amateur question. I'm a javascript developer.

Right now I have a function that gets the content of the field cta_text for each custom post type of promotions.

How would I iterate through this code to add multiple custom fields? i.e. cta_text, cta_url, etc

add_action('rest_api_init', 'register_post_custom_field');
function register_post_custom_field() {
        register_api_field( 'promotions',
            'cta_text',
            array(
                'get_callback'    => 'get_custom_field',
                'update_callback' => null,
                'schema'          => null,
            )
        );
    }

function get_custom_field( $object, $field_name, $request ) {
        return get_post_meta( $object[ 'id' ], $field_name, true );
    }

avnaveen on "How to get all the gallery images using nextgen gallery name"

$
0
0

Hello guys,

By using the below php code, we will be able to get all the images present in the nextgen gallery with an id value of 8

global $nggdb;
$gallery = $nggdb->get_gallery(8, 'sortorder', 'ASC', true, 0, 0);
foreach($gallery as $image) {
    echo $image->imageURL;
    echo $image->alttext;
    echo $image->description;
 }

Is there a way to get all the images inside a gallery with the help of gallery name?

amurado on "Code to Display Future Posts is Affecting My Media Library"

$
0
0

Hi,

I'm currently using the following code in my functions.php file to display scheduled posts for the custom post type "movies".

//DISPLAY FUTURE POST TYPES
add_filter( 'pre_get_posts', 'get_future_posts' );
function get_future_posts( $query ) {
	if ( is_home() && $query->is_main_query() )
		//IF YOU WANT TO INCLUDE CUSTOM POST TYPES
		$query->set( 'post_type', array( 'post', 'movies' ) );
		//INCLUDE POSTS WHOSE STATUS IS BOTH PUBLISHED AND FUTURE
		$query->set( 'post_status', array( 'publish', 'future' ) );
	return $query;
}
// SHOW FUTURE POSTS SINGLE.PHP
function show_future_posts($posts){
	global $wp_query, $wpdb;
	if(is_single() && $wp_query->post_count == 0){
		$posts = $wpdb->get_results($wp_query->request);
	}
	return $posts;
}
add_filter('the_posts', 'show_future_posts');

However, while this code works great for what I want it to do, I noticed it for some reason affects my media library. Whenever I go to my media library or try and insert an image through media library it always tells me "No media files found." even though I know there is. When I remove the code above, it shows me all the images like normal.

Any ideas on how this is being affected and what I can do?

Thank you

ctuxboy on "WooCommerce disable 'Flat Rate' shipping"

$
0
0

Hello,

Today updating WC to the latest version.
There are new shipping methods.

When buying for more then 100€ then is free shipping.
In the previous version, i have a solution for this.
I place this code in the functions.php for hiding the 'flat_rate' shipping:

function hide_shipping_when_free_is_available( $rates, $package ) {

 	// Only modify rates if free_shipping is present
  	if ( isset( $rates['free_shipping'] ) ) {

  		// To unset a single rate/method, do the following. This example unsets flat_rate shipping
  		unset( $rates['flat_rate'] );

  		// To unset all methods except for free_shipping, do the following
  		$free_shipping          = $rates['free_shipping'];
  		$rates                  = array();
  		$rates['free_shipping'] = $free_shipping;
	}

	return $rates;
}

In the latest WooCommerce version this function doesn't work anymore.
Who can help me find a solution for this?
(I think it's another hook for flat_rate shipping)

Christophe

Viewing all 8245 articles
Browse latest View live




Latest Images