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

vahidmoghadam on "how to upload image from url and set featured image"

$
0
0

hello,
i want to upload an image in my wordpress library from URL and set it as featured image in own plugin. how i do and coding it?
thanks


katrah on "Shortcode to display categories the post is listed under on the current post"

$
0
0

I've been searching high and low and can't seem to find how I can accomplish this.

I would like a shortcode that I can put into my post where it will display all the categories that post is listed under.

Any ideas? I've been searching for about 1/2 day now and have come up short.

Taro on "Search result based on menu category"

$
0
0

Hi All,

i'm looking for two pieces of code that can help me with the following:

I got posts and pages with a custom menu. These posts/pages got a custom template activated. The templates contains the menu for the specific posts and pages. This way i can order pages/posts in two different categories.

Now i like to change the search function; the search output should be based on the active custom menu category.

I named menu 1: Benelux and menu 2: International

1: First peace of code needs to be for the searchform.php
The code should look at the current active menu(category) and the search result should be based on the active menu.

If the menu is for example "Benelux" then the search result should only display pages/posts from the custom taxonomy that i made <input type="hidden" name="location" value="benelux" />
Or if the active menu is "International" then display pages/posts from the custom taxonomy <input type="hidden" name="location" value="international" />

I found the following code to get the menu category...not sure if this is useful..

(wp_nav_menu( array(
    'menu' => 'benelux'
) )

2: Second peace of code is needed for the search.php (header).
Because if the output should work correctly than we also need to change the menu for this search result page. Default the search.php uses the main menu.

So the following code needs to see if the pages/post contain taxonomy benelux or international and change the menu accordingly.

It would just be really awesome if this is possible.

Greatings,
Taro

jplwood on "Sub Pages on Custom Post Type with Advanced Custom Fields PRO"

$
0
0

I have a Custom Post Type called "Projects". I have a page-projects.php that displays all of the projects. Then a single-projects.php to display a single project. Trouble is, I want the display for a single project to sort of be its own little mini sub site.

I've set up the Projects Custom Post Type with Advanced Custom Fields PRO and using the Repeater type, I made it so users can enter in a title, slug and content for that internal page for each project.

I tried using Anchor Tags (e.g., #home or #about) for each page, and hiding/showing tabs (these sub pages) with JQuery, but there's a huge lag when the page first loads (assuming because of the huge burden placed by scripts loading from plugins). So the JQuery that will ultimately display the correct "page" indicated by the anchor tag takes a few seconds before it displays the right content. -- not ideal.

Do any of you have any ideas for me about the best way I can accomplish this functionality (i.e., sub pages on a custom post type's single-[post] view)?

Marcelo Pedra on "Any way to run a code after plugin/theme update?"

$
0
0

I'm looking for some way of hooking themes/plugins updates and run a script to patch custom modifications in specific plugins and/or theme files. This way, you could update your assets and schedule a task to reaaply patches in auto pilot.

Any idea? Could this be really possible?

andrewlux on "Custom plugin not allowing access to wp-admin"

$
0
0

I'm making my first Wodrpress widget. Something simple that lets you put in social link buttons into a sidebar. I followed tutorials that told me to wrap the widget in a plugin, and I got it working fine, however when I tried to log out or log in again I got just a white screen. I removed the folder from the plugin directory and I could access wp-admin fine. if I'm already logged in and make the plugin i made active, everything works fine. Its just the wp-admin screen is totally white when the plugin is activated.

Here is the plugin code

class social_widget extends WP_Widget {

  public function __construct(){
      $widget_ops = array('classname' => 'social_widget', 'description' => 'Displays an My widget!' );
      $this->WP_Widget('social_widget', 'Social Buttons', $widget_ops);

  }

  function widget($args, $instance) {
    extract($args, EXTR_SKIP);

    $fb = $instance['facebookk'];
    $link = $instance['linkedd'];
    $twit = $instance['twitterr'];
    echo $before_widget;

    if ( $fb ) : ?>
      <a href="<?php echo $fb; ?>" target="_blank"><img id="contlink" src="<?php bloginfo('template_directory'); ?>/images/fb-wht.png"></a>
    <?php endif;
    if ( $link ) : ?>
      <a href="<?php echo $link; ?>" target="_blank"><img id="contlink" src="<?php bloginfo('template_directory'); ?>/images/linkeded-wht.png"></a>
    <?php endif;
    if ( $twit ) : ?>
      <a href="<?php echo $twit; ?>" target="_blank"><img id="contlink" src="<?php bloginfo('template_directory'); ?>/images/twitter-wht.png"></a>
    <?php endif;
    echo $after_widget;
  }

public function form($instance){
$instance = wp_parse_args( (array) $instance, array( 'facebookk' => 'your mom') ); ?>

<p>
<label for="<?php echo $this->get_field_id('facebookk'); ?>"><?php _e('Facebookk', 'social_widget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('facebookk'); ?>" name="<?php echo $this->get_field_name('facebookk'); ?>" type="text" value="<?php echo $instance['facebookk']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('linkedd'); ?>"><?php _e('Linkeddin', 'social_widget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('linkedd'); ?>" name="<?php echo $this->get_field_name('linkedd'); ?>" type="text" value="<?php echo $instance['linkedd']; ?>" />
</p>
<p>
<label for="<?php echo $this->get_field_id('twitterr'); ?>"><?php _e('Twitterr', 'social_widget'); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id('twitterr'); ?>" name="<?php echo $this->get_field_name('twitterr'); ?>" type="text" value="<?php echo $instance['twitterr']; ?>" />
</p>
<?php

  }

public function update($new_instance, $old_instance) {
    $instance = $old_instance;
    $instance['facebookk'] = $new_instance['facebookk'];
    $instance['linkedd'] = $new_instance['linkedd'];
    $instance['twitterr'] = $new_instance['twitterr'];
    return $instance;
  }

}

add_action( 'widgets_init', create_function('', 'return register_widget("social_widget");') );

enquirer32 on "Core breadcrumbs navigation overrides 'private' status"

$
0
0

I am running the core navigation feature for posts navigation which give one the option for using breadcrumbs as included in wp-includes/link-template.php. Unfortunately, when an author is looking at their own private post the breadcrumbs feature enables them to skip to previous/next of all posts which are also private but not theirs... any suggestions how to fix this?

aleykey on "How to get Values from FrontEnd User Form and display in WP Admin Panel?"

$
0
0

Hello guys,

Iam tryring to get Values from a Form which i have included in the FronEnd (RadioButton Value and Text Input Value) to display in the Wordpress
BackEnd or AdminPanel, so I need to have a Admin Menu to get the Values, a specific user (E-Mail Adress) entered in the Form and display this Values in the Backend.

I am using a Newsletter Plugin its called MyMail for WordPress. I want to know why Users unsubscribe to my Newsletter by letting them check Radio Buttons with Reasons or write a Text in a Textarea input.
I modified the unsubscribe form and added some radio buttons and a textarea heres the code:

...........

$html = '';

$html .= $this->get_styles();

$action = 'mymail_form_unsubscribe';

$html .= '<form action="'.$this->get_form_action($action).'" method="post" class="mymail-form mymail-form-submit mymail-ajax-form" id="mymail-form-unsubscribe">'."\n";
$html .= '<div class="mymail-form-info '.$infoclass.'">';

$html .= $this->get_message();
$html .= $this->message;
$html .= '</div>';
$html .= '<input name="hash" type="hidden" value="'.$this->hash.'">';
$html .= '<input name="campaign" type="hidden" value="'.$this->campaignID.'">';

if(!$this->hash){

$html .= '<div class="mymail-wrapper mymail-email-wrapper"><div class="mymail-form-fields">
<div class="mymail-form-info-checkbox">
<fieldset id="gruende">

  • <label> <input id="one" class=".myCheckbox" type="radio" name="reason" value="notwanted"> Ich habe mich nie für diesen Newsletter angemeldet </label>
  • <label> <input id="two" class=".myCheckbox" type="radio" name="reason" value="notrelevant"> Die im Newsletter genannten Themen sind für mich nicht relevant </label>
  • <label> <input id="three" class=".myCheckbox" type="radio" name="reason" value="notinterested"> Ich erhalte zu viele Newsletter </label>
  • <label> <input id="four" class=".myCheckbox" type="radio" name="reason" value="often"> Ich bin an der Zeitarbeitsbranche nicht mehr interessiert </label>
  • <label> <input id="otherreasons" type="radio" name="reason" value="otherreason"> Sonstiges: </label>
  • <label> <input style="height: 125px; width: 80%;" id="otherreasontextfield" type="text" name="ownreason" value="" placeholder="Bitte geben Sie einen Grund an"></label>
</fieldset>
</div><div id="emailproof"><label for="mymail-email">'.mymail_text('email', __('Email', 'mymail')).' <span class="mymail-required">*</span></label>';
$html .= '<input id="mymail-email" class="input mymail-email mymail-required" name="email" type="email" value="">';

}
if($subscriber && $single_opt_out){
}else{
$buttontext = mymail_text('unsubscribebutton', __('Unsubscribe', 'mymail'));
$html .= '<div class="mymail-wrapper mymail-submit-wrapper form-submit"><input name="submit" type="submit" value="'.$buttontext.'" class="submit-button button"></div>';
$html .= '</div></div>';
}
$html .= '</form>';

return apply_filters('mymail_unsubscribe_form', $html, $this->campaignID);
}

..............

Hope somebody can help me with this.
Best Regards.

AleyKey


baburman on "How to add columns in a Custom Post Type list in Admin."

$
0
0

Hi,

I have created a Custom Post Type 'ads', which is working fine on both admin and user end. Now I have to create a couple of columns in the CPT default listing page in WP admin.

I have created label for the fields like this:

function adm_ads_table_head( $defaults ) {
$defaults['ad_expire_date'] = 'Expiry Date';
$defaults['ad_clicks'] = 'Clicks';
return $defaults;
}

and the function is hooked like this:

add_filter('manage_ads_posts_columns', array( $this, 'adm_ads_table_head'));

so far so good. Now I have to set content for the above columns. I have used this simple function to make it work.

function adm_ads_table_content( $column_name, $post_id ) {
if ($column_name == 'ad_expire_date') {
//echo '121212';
//echo get_metadata('ads', $post_id, '_ad_dtexp', true);
echo get_post_meta( $post_id, '_ad_dtexp', true );
}
}

and this is the hook:

add_action( 'manage_ads_posts_custom_column', array( $this, 'adm_ads_table_content') );

The problem is when i echo any static value like '121212' it successfully shows in the Expiry Date column. But when i try to use

get_metadata or get_post_metadata, nothing displays in that column. Please help!!!

baburman

onmas on "Calling a plugin across two scripts"

$
0
0

Hi everyone.

This is my first post - I hope I've asked it correctly.

I need to make a call from Wordpress (using Ajax) out to a script (CALL_SHORTCODE.php below) to retrieve some data from a table. To do this, the 1st script needs to call another script (TEST_SHORTCODE.php) to get the login name of the user from a plugin.

WP (ajax) --> CALL_SHORTCODE.php --> TEST_SHORTCODE.php

I'm not getting any data back in CALL_SHORTCODE.php. However, if I just call TEST_SHORTCODE.php without calling it from CALL_SHORTCODE.php I get data I want (eh?). The following code will run.

[CALL_SHORTCODE.php]

<?php
  // Call our script to get who's logged in
  $jsonurl = "http://my.url.com/scripts/TEST_SHORTCODE.php";
  $json = file_get_contents($jsonurl);
  var_dump($json);
?>

[TEST_SHORTCODE.php]

<?php
  // Include Wordpress
  // Tried using wp-blog-header.php as well to no avail
  include_once '../wp-load.php';

  // Get login name from Memberpress and return it
  $username = do_shortcode("[mepr-account-info field='user_login']");
  $rows[] = array( 'username'=>$username );
  echo json_encode($rows, JSON_NUMERIC_CHECK);
?>

...Output from calling TEST_SHORTCODE.php (valid JSON):

[{"username":"foo.bar@gmail.com"}]

...However, the output from calling CALL_SHORTCODE.php is:

string(17) "[{"username":""}]"

...As you can see, there is no value in the output of CALL_SHORTCODE.php.

This one is driving me bonkers :)

Many thanks in advance
Jason

ftwwings on "wp_redirect not working"

$
0
0

So i have been trying deferent things of same code, and always return an error:

Parse error: syntax error, unexpected 'function' (T_FUNCTION) in /home/tzjelenje/tz-jelenje.dreamhosters.com/wp-content/themes/colormag/functions.php on line 3
line 3

in this case is : function redirect_visitors() {

Code is :

add_action( 'init', 'redirect_visitors' )
function redirect_visitors() {
if ( ! is_user_logged_in() && is_front_page() ) {
wp_redirect( 'http://www.tz-jelenje.dreamhosters.com/readme.html', 301 );
exit; } }

babawebzdev on "Woo commerce Pagination Issues"

$
0
0

Need to move Sold out at last page of Woo commerce Pagination is any hook available

Ab C on "Execute admin script/action on front-end event"

$
0
0

When a front-end user (role: Subscriber) performs a certain action (click a button, for example), I need a new post to be created. Now I can call wp_insert_post in the page template I'm using but the Subscriber role does not have permission to create a post (in published state). Other than giving the subscriber a higher role, are there any other options?

I was wondering if I can simply invoke an admin action from the page template that will publish a new post. Is there any way to change the user context (to author or up) before calling wp_insert_post? This needs to be done programmatically.

Thanks in advance,
Aj

itsjaked on "Rewrite Rule with Front Page"

$
0
0

Hello,

I am working on a custom plugin and I have the following rewrite rule:

add_rewrite_rule(
'(.+?)/([^/]+)/([^/]+)/?$',
'index.php?pagename=$matches[1]&state=$matches[2]&city=$matches[3]',
'top'
);

It's working on all pages but the homepage. Whenever I try to pass parameters to the homepage it automatically redirects to the root.

For example if I type in domain.com/state/city it send me straight to domain.com and I am not able to get the parameters.

I have tried to add the following rewrite rules with no avail

add_rewrite_rule(
'([^/]+)/([^/]+)/?$',
'index.php?pagename=home&state=$matches[1]&city=$matches[2]',
'top');

add_rewrite_rule(
'(.+?)/([^/]+)/([^/]+)/?$',
 'index.php?state=$matches[2]&city=$matches[3]',
'top'
);

I'm guessing there is a built in WordPress redirect that automatically redirects anything referencing the static homepage to the root, but I'm not sure.

Any ideas on how to get this working?

Thanks so much!
Jake

oraysion on "Glick to large image (media)"

$
0
0

I know how to set the image to link to media when it is uploaded to MEDIA. But by default it has not been doing that and the settings are NOW set to do that. But for about 6 months it was not. Is there a way to override settings or code a way to make EVERY image i click on go to the largest media file?


Bat n Ball on "Number-only username?"

$
0
0

Hello,

Does anyone know if it is possible to restrict usernames to numbers only?

Also, is it possible to restrict the number length to, say, 10? No more and no less.

I am in the early stages of putting together a business case for a client who requires only numbers to be used as a username. This number is a unique identifier to their staff in their organisation, for example: 2398253635.

Any help and guidance very much appreciated.

Paul.

daveetasac on "Need to include custom fields in meta box select menu output"

$
0
0

Hello,

I've created a site to allow businesses to showcase their stores and associated coupons. In the front-end, they can select from a list of stores they've created, and can even see the address of each location in the dropdown as well. In the back-end, however, I can only view their name from the theme's custom post type meta box. This is a problem for me in case I need to update something, mainly because there might be multiple stores with the same name, and I have no to see which exact store is being referenced.

I'm using ACF Plugin for the custom fields.

Here's the code that works in the front end:

<select name="offer_store" id="offer_store" class="form-control" data-validation="conditional" data-conditional-field="offer_new_store" data-error="<?php esc_attr_e( 'Select the store this coupon is valid for', 'couponxl' ); ?>">
			        	<option value=""><?php _e( 'Select the store this coupon is valid for...', 'couponxl' ) ?></option>
				        <?php

						$stores = couponxl_get_custom_list( 'store', array(
							'author' => $current_user->ID,
							'orderby' => 'title',
				        	'order' => 'ASC',
							'posts_per_page' => '-1',
				        ) );

				        if( !empty( $stores ) ){
				        	foreach( $stores as $store_key => $store_name ){
								$address = get_field( "store_address_1", $store_key );
								$city = get_field( "store_city", $store_key );
								$state = get_field( "store_state", $store_key );
				        		echo '<option value="'.$store_key.'">'.$store_name.'&nbsp;&nbsp;( '.$address.',&nbsp&nbsp;'.$city.',&nbsp;&nbsp;'.$state.' )'.'</option>';
				        	}
				        }
				        ?>
			        </select>

I'm not sure how to insert the above code into the array below; I'm trying to show the address info next to the store name:

array(
			'id' => 'offer_store',
			'name' => __( 'Offer Store', 'couponxl' ),
			'type' => 'select',
			'options' => couponxl_get_custom_list( 'store', array(), 'title' ),
			'desc' => __( 'Select store of the offer.', 'couponxl' )
		),

Thanks in advance.

sharkonda on "Imagemapster Jquery Plugin"

$
0
0

Hi, I'm using Imagemapster for adding a hover effect to my header image. I successfully load the imagemapster.js, my script (also .js in theme folder), but nothing seems to happen. I've already digged around on Google for answers, and I've found nothing that works.
Here's the code:
jQuery(document).ready(function($) {
$('#navigacija'}.mapster({
singleSelect : true,
clickNavigate : true,
mapKey: 'color',
fill : true,
altImage : 'wp-includes/images/files/posaoodkuce-nav-image-hover.gif',
fillOpacity : 1,
});
});`

here's the site: http://posaoodkuce.com/

amybryde on "Modify search results page to table - code for loop?"

$
0
0

The search results page looks horrible and I would like to modify to present a table since the search will mostly be used as a parts search. All inventory has been divided up into categories with 1 category being our Master Inventory list. Unfortunately, since the files are so large, I had to use the "Embed a document" plugin to create most of the pages of inventory.

After must research, I have found that I need to modify the look within the search.php file. My problem is that I am unsure what code to use to have it display correctly as a 6 column table (Part Number, NSN, Alt. P/N, description, condition and quantity) showing only the part number information searched. The data would have to be pulled from the data created from the "Embed a document" plugin. I am simply at a loss of how to create the needed loop to display this correctly so that just the part number search shows up instead of the whole long list of inventory.

As an example, try searching "50-8792-3"

The website is http://www.calportaviation.com.

Any help with the coding would be much appreciated!

Thank you!

poopymonster on "Formatting Images generated by shortcode"

$
0
0

I'm testing some scrape plugins, and finally found one that serves my needs. However the images are displayed vertically, with no option to change it.

Is there a way to make the images appear in a grid?

Example of a shortcode I need to use in a post to display the craped content:
[wpws url="http://imgur.com/a/s9CIv/all" query=".posts" ]

How the shortcode gets rendered:
http://www.koffid.nl/mem/rg-6/

Thanks!

Viewing all 8245 articles
Browse latest View live


Latest Images