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

Dave Navarro, Jr. on "Filter Media in Media Uploader"

0
0

I have a form on my site that allows a logged in user to create a custom post type. I allow the user to insert media into the post content.

When they click the "Add Media" button, it displays the WP standard media upload dialog. That dialog allows the user to select from ALL media uploaded to the site. I'd like to restrict it to only allow media the user has previously uploaded.

Is there a filter/hook for displayed media?


fooshy on "Changing the term "Username or Email" on both Login & Forget Password Screens"

0
0

Hi there

Is it possible to change the term "Username or Email" on both Login & Forget Password Screens?

I have a project where my staff are registering as subscribers however we are mapping their 'Client Pin' to be their username. I need it say "Pin" on both Login & Forget Password Screens instead of "Username or Email"

salar2016 on "add button in meta box for quick update post"

0
0

i want to add new meta box for update post published to current time !
when click on button published date in custom post type change time published to current now!
my code something like this:
` $publish_date = current_time('mysql');
$my_post = array(
'ID' => $ID,
'post_date' => $publish_date,

);

wp_update_post( $my_post );

Julian on "How to Edit general-template.php Without Editing Core Files"

0
0

Hi there,

I am trying to set up human time difference on my WordPress website, but in order to do so, I need to overwrite echo apply_filters( 'the_time', get_the_time( $d ), $d ); with echo human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'; in general-template.php.

However, I do know that I should never edit core files. Therefore, I do have a child theme, and so I am wondering if anybody knows how I could possibly complete this action through either my child theme or some other way?

Thank you very much,

Julian M.

StelleDiPolvere on "How to Disable Creation of Image Attachment Pages for Uploaded Images"

0
0

Hi Guys :)
This is an unresolved question for many years...
The creation of the above-mentioned Image Attachment Page created problems to many about SEO... Someone solved With a redirect method...
But sometimes, something weird can happen:
I was uploading on the Home page an Image called Services...
Wordpress created an attachment page called mydomain.com/Services and assigned that to the image just uploaded
So when I was trying to create the actual page SERVICES i was not able to do that... and that was sad and funny :)

Anyone knows if it is possible to hack the core of WordPress to avoid the creation of pages that contain the image just uploaded?
Thank you in advance for your replies :)

Victor Fdez on "Shotcode with two actions (show a div ans execute an insert)"

0
0

Hi,
I am coding a shortcode that créate a button that have to execute two actions:
1 -> Show a div (a spoiler button)
2 -> Insert a value in a table of the database

The problema that I have is because i don't know how the button can do the both actions, actualy the button only show the div.

Code of the shortcode:

function shortcode_telefono($atts, $content = null) {
return'<input type="button" onclick="if(document.getElementById('spoiler1') .style.display=='none') { document.getElementById('spoiler1') .style.display=''; this.value = 'Ocultar';}
else{document.getElementById('spoiler1') .style.display='none';this.value = 'Mostrar'; }" value="Mostrar"/>

<div id="spoiler1" style="display:none">

<p id="texto-anuncio">'.$content.'
</div>';
}
add_shortcode('telefono', 'shortcode_telefono');

Query that i want to add in the button
global $wpdb;
$wpdb->query('INSERT INTO CONTADOR_CLICKS (ID, FECHA) VALUES (1,NOW())');

How can i create a shortcode that insert in the post a button that do both things?
I know that exists plugins that do something like that, but I need the functionality in a shortcode.

Thanks.

roma100 on "Help with swfobject.js"

0
0

Hi.

As a newbie to website building I need some help .......

My site which is under construction is receiving some interest from unwanted visitors. It appears that by using the following extension:

http://www.website.com/wp-content/themes/purevision/sliders/swfobject.js

they gain access to my site even though I am not using a purevision theme.

Can someone guide me on how to close down entry to my site so that when they type in the above address they are confronted with a blank page / 404 denying further possible access.

Regards
Roma100

cfurrow on "the_post action not working"

0
0

Hello! I'm pretty new to the inner workings of wordpress and I'm having a problem trying to get a function to display in my custom post type.

Ideally, I'd like to have a bit of html automatically added to the front end of my custom post type every time I publish a new one.

from what I understand, putting this in my child theme's functions.php should have done it:

add_action( 'the_post', 'teaching_part_one' );
function teaching_part_one(){
    ?>
    <p>custom code</p>
    <?php
}

but when I put that in and update it, it will display

"custom code custom code
custom code custom code
custom code custom code"
etc...

in the header of every page on my site, which confuses me, because I thought that would hook into (not sure if i'm using that correctly) the posts on my site.

Would anybody know what I might be doing wrong, and how I might be able to add code that will display in all of my posts automatically, preferably to the child theme?

thanks for reading my post, and thank you in advance for the help!


nomansajid on "Append a string to my post using is_user_logged_in()."

0
0

Hello there! I am developing a website and my client wants that a hard coded string should be added to every post title if visitor is not logged in. how can I do this. I have used concatenation way to approach it but, seems like not working. Here is some code that i have done in the_title function in post-template.php
{
if (!is_user_logged_in()) {
$title .= "$title (string goes here...)";
return $title;
}
else
return $title;

}

zaccreative on "Want to display an image automatically according to post rating"

0
0

Good Day, Can anyone help? I am trying to achieve a rating system similar to that of Rotten tomatoes movie rating site. https://www.rottentomatoes.com/. Is there a plugin i can use to achieve this? Or is there a tweak i can do? What i want to achieve exactly, is to have a picture displayed automatically according to the rating received for a post. Thanks in advance.

ncsm on "save wordpres information in new database (using wp shortcodes)"

0
0

hello every body :)
hop to have a good day :)

my friends I have a site based on wordpress that I get author id and post id by following codes :

[ Moderator note: code fixed. Please wrap code in the backtick character or use the code button. ]

<؟php
echo (the_author_meta('ID') ); //author id

echo (get_post_field('ID', $post_id)) ;//post id
?>

now I want save this details in other data base but I cant :(

who know true Answer??

... by the way I must say that when I insert my data in new db null result fill in that :(

heydavid on "how can I make the search return only single random correct result?"

0
0

look, i ve searching for a long time that can not find anything about this, but lots of questions about "how to fix the problems like showing only one result"...but the mistake-result they made seems not what i need, because i need to show the Correct Result which hit the keywords, AND, everytime you search, it turn out to be another random result, but not by time or other logics.

Please tell me which file i should change, function.php or search.php? and what code i should add or fix?

hausexpress on "Function Needed Increase Price Output - Woocommerce Google Product Feed"

0
0

I am utilizing the Woocommerce Google Product Feed Plugin. I already have another Plugin that is dynamically increasing the price of the Woocommerce Product without changing the price in the database.

However the Woocommerce Google Product Feed Plugin is pulling the price from the database. So I need to increase the price outputted by the Woocommerce Google Product Feed Plugin, for example 10%.

Here is what I have so far.

/**
* Price Change
*/
function return_custom_price($price, $product) {
global $post, $blog_id;
$price = get_post_meta($post->ID, '_regular_price');
$post_id = $post->ID;
$price = ($price[0]*1.1);
return $price;
}
add_filter('woocommerce_gpf_price', 'return_custom_price', 11, 2);

milanparmar22 on "WP Plugin: Unable to Print javascript in header"

0
0

I am developing a plugin. The plugin needs javascript code in header. In order to print the code only in header of plugin's setting page. I am unable to do that. I have referred instructions here

The plugin works fine if javascript is printed using this plugin

I also tried to add code within body (after div) by below method....

include( plugin_dir_path( __FILE__ ) . 'ipn/javascript.php');

But that to did not work.

Check the plugin code....

add_action( 'admin_enqueue_scripts', 'my_enqueued_assets' );

function my_enqueued_assets() {
wp_enqueue_script('Google_jquery', 'http://code.jquery.com/jquery-2.2.4.min.js');

}

add_action('admin_menu', 'my_plugin_menu');
function my_plugin_menu() {
add_menu_page('My Plugin Settings', 'Plugin Settings', 'administrator', 'my-plugin-settings', 'my_plugin_settings_page', 'dashicons-admin-generic');
}

function my_plugin_settings_page() {
global $my_plugin_settings;

echo 'HTML Form code here';
add_action( "admin_head-{$my_plugin_settings}", 'my_admin_head_script' );
}
function my_admin_head_script() { ?>

// javascript code that i want to print in header

<script type="text/javascript">$(function() {
var scntDiv = $('#p_scents');
var i = $('#p_scents p').size() + 1;

$(document).on('click','#addScnt', function() {
        $('html code here').appendTo(scntDiv);
        i++;
        return false;
});

$(document).on('click','#remScnt', function() {
        if( i > 2 ) {
                $(this).parents('p').remove();
                i--;
        }
        return false;
});
});</script>
// javascript code end

<?php }
add_action('admin_head', 'my_custom_fonts');

function my_custom_fonts() {
echo 'CSS style here';
}

dakrw1nd on "Add user profile button to theme menu"

0
0

I'm new in wordpress development, Can you help me with this question:

I installed latest wordpress version and latest plugin buddypress version. Now I disabled wordpress admin bar for non admin users and I want move user profile button (screenshot below) into my theme Menu. https://s31.postimg.org/b0s2okcu3/one.png

My menu: https://s31.postimg.org/5dvpr3abf/two.png

Now I created new Menu items with login / logout / edit profile functions, but I dont understand how to insert user profile button into my menu.

There is my code:

function wpse_125929_login_logout( $items ) {
    if ( is_user_logged_in() ) {
        $current_user = wp_get_current_user();
        $profile_edit_url = admin_url( 'user-edit.php?user_id=' . $current_user->ID );
        $profile_link = '<li><a href="' . $profile_edit_url . '">Edit Profile</a></li>';
        $logout_url = '<li><a href="'. wp_logout_url() .'">Logout</a></li>';
        $items = $items. $profile_link. $logout_url;
    } else {
        $login_link = '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
        $items = $items. $login_link;
    }
    return $items;
}
add_filter( 'wp_nav_menu_items', 'wpse_125929_login_logout' );

How I can add user profile button to my menu?

Thanks in advance!


Janell2 on "Change to theme-functions.php - add_image_size"

0
0

First, I apologize if this is not the place to ask this question ...for help!

I have a theme that has a way for Client logos to display by category on a PAGE. You fill in a "Client" post for each logo you want to add (by making the featured image the logo), and then on the Page, you select the Shortcode for "Client" and then on that shortcode form you select what category you want the logo to display under. GREAT!

However, the logos are set in the theme-functions.php as 75px square. Much too tiny to be able to read. I wish they had let us set the size. I was able to, by great convoluted coding in the CSS, get it to display to the size I want, but it STILL creates the image to 75 pixels, so actually I am blowing up the logo and it looks terrible.

I of course bought support for the theme, but they tell me this would be a modification to theme files & therefore can't help (I understand) but he did tell me that the size call out was in theme-name>functions>theme-function.php. I know I found the correct code as the support person did say that the clients-slider worked for the slider as well as the non-slider:

/* ---------------------------------------------------------------------------
 * Add Image Size
 *
 * TIP: add_image_size ( string $name, int $width, int $height, bool|array $crop = false )
 * --------------------------------------------------------------------------- */
if( ! function_exists( 'mfn_add_image_size' ) )
{
	function mfn_add_image_size() {

		// Backend --------------------------------------------

			// Featured Image
			set_post_thumbnail_size( 			260,  146,  false );

			// Custom Post Format - List Thumbnails
			add_image_size( '50x50', 			50,   50,   false );

		// Builder Items --------------------------------------

			// Clients - do NOT crop logos
			add_image_size( 'clients-slider', 	150, 75,   false );

I changed it to: add_image_size( 'clients-slider', 150, 110, false );
BUT it did not work.

Anyone know what I am doing wrong? Your help would be very much appreciated! I would love to post the URL of the site, but HOSTGATOR just stopped allowing temporary URLs (YIKES!)
Thanks so much,
Janell

pnbnsv on "Adding a description to a specific shiping method"

0
0

Hi there,

I have been able to add a description to every shipping method that shows in the cart, but I need to assign it for a specific shipping method only and not for all of them.

Please check the screenshot.

Any help?

Thanks.

itssmohammed on "How to add a radio player that work on all platforms?"

0
0

Hello, I have a personal radio that I want to add to the website and I've looked in google and got one from (https://www.muses.org/setup) but the problem with their radio player is: it doesn't work on Android phones.

So is there a change of code I can do to make it work or a plugin that let me put my own radio link and compatible with android phones?

That's the link to the radio page on my website: http://www.arabi-group.com/en/?page_id=292

And here is the code for the radio player:

<!-- BEGINS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->
<script type="text/javascript" src="https://hosted.muses.org/mrp.js"></script>
<script type="text/javascript">
MRP.insert({
'url':'http://arabifm.com:8000/stream',
'codec':'mp3',
'volume':100,
'autoplay':false,
'buffering':5,
'title':'Arabi Group',
'welcome':'Arabi Group',
'bgcolor':'#FFFFFF',
'skin':'bogusblue',
'width':660,
'height':266
});
</script>
<!-- ENDS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->

diondkb on "Preg_replace not working"

0
0

Hi,

Is there any reason why preg_replace should yield different results if run on an online test tool like http://regexr.com/ as opposed to running it in the wordpress context.

When this the following is run in the wordpress context, it finds a match and does the replacement, but not when run on two online regex tools.

The syntax is

return preg_replace('/\.mp3(?!\?name)(?!"])/',
                            '.mp3?name=[current_user]',
                            $content
                        );

The string to search is:
'[html5_audio src="https://s3.amazonaws.com/sfs-premium/collection/Rider+Aids/Seat+Aids+and+Feel/Learning+How+to+Stop+Driving+with+Your+Seat/686-Learning-to-Stop-Driving-with-Your-Seat.mp3"]'

Running the expression on the online tool, yields:
[html5_audio src="https://s3.amazonaws.com/sfs-premium/collection/Rider+Aids/Seat+Aids+and+Feel/Learning+How+to+Stop+Driving+with+Your+Seat/686-Learning-to-Stop-Driving-with-Your-Seat.mp3"]

while run in the wordpress environment yields:
[html5_audio src="https://s3.amazonaws.com/sfs-premium/collection/Rider+Aids/Seat+Aids+and+Feel/Learning+How+to+Stop+Driving+with+Your+Seat/686-Learning-to-Stop-Driving-with-Your-Seat.mp3?name=[current_user]"]

Does wordpress add chars causing the opposite results?

Any help will be appreciated.

Dion

ferocious on "Attach CPT to submenu"

0
0

I'm currently developing a plugin that is using a Custom Post Type. I'd like to register my CPT and put it under another sub-menu. For example, main menu is STORE and the sub-menu is PRODUCTS.
I followed the guide lines from this blog entry
How to add a custom post type into the sub-menu of a custom menu
and I am still unable to add a new CPT, I get the following error message:

You do not have sufficient permissions to access this page.

Everything works perfectly if I use CPT with his top-level menu otherwise I can only read, delete and edit CPTs but I can't add new ones.
What is the correct way to attach the CPT into the submenu PRODUCTS?
Here my php code

function register_cpt() {
if ( is_user_logged_in() && current_user_can( 'edit_others_products' ) ) {
	$show = false;
} else {
$show = true;
}
$args = array (
'public' => true,
'hierarchical' => false,
'has_archive' => true,
'show_ui' => true,
'show_in_menu' => $show,
);
register_post_type( 'mf_product', $args );
}

function setup_menu() {
add_menu_page( ... ); // menu_store
add_submenu_page( 'menu_store', 'Product Editor', 'Product Editor', 'edit_others_prodcuts', 'edit.php?post_type=mf_product', NULL );
}
Viewing all 8245 articles
Browse latest View live




Latest Images