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

jete@multiweb.nl on "fatal eror in wp-includes/pomo/streams.php"

$
0
0

Hi,
After an update of one of my plugings my wordpress site doesn't work anymore. I can only log into the site and access files, the admin function is also dissabled.

Fatal error: Allowed memory size of 54525952 bytes exhausted (tried to allocate 207 bytes) in /mounted-storage/home135/sub005/sc32087-RPOB/jete.nl/blog/wp-includes/pomo/streams.php on line 71

Who can help me?

Jack


dedepress on "How to get $_GET var on customize.php?"

$
0
0

I'm trying to do something with $_GET vars on customize.php page, but It is quite difficult than I expected.

//======== Example

WP Version: 4.0-beta4
Also tested with 3.9.2, so I think it's not a wp beta version bug.

URL:

http://localhost/wp/wp-admin/customize.php?var=google

Code:

add_action('customize_register', 'testing');

function testing($wp_customize) {

    // this can't get vars and throw a undefined index error,
    // but if I check source code of the page, I can see it's here.
    print_r($_GET[var]);

    // Notice: the stuff below inside will render properly,
    // in other words, I got the var once,
    // but it cause another fatal problem:
    // the setting which added inside here will not be saved.
    if(!empty($_GET[var]) {
        $wp_customize->add_setting(...);
        $wp_customize->add_control(...);
    }

}

if I hook the testing() function to 'customize_controls_init', I'm able to get $_GET vars and no errors, but it also cause the same problem: the settings will not be saved.

seems it's caused by iframe and refresh, but I tried a variety of ways and still can't make it working well.

Anyone have an point? Thanks in advance.

lindorblu on "search by tags"

$
0
0

Hi!
I need to modify this part of code to have search by tags.

<?php
						$author_args = array(
									'taxonomy'        =>'authors',
									'show_option_all' => __( 'All Authors', 'raakbookoo' ),
									'hide_empty'      => 1,
									'orderby'         => 'slug',
									'order'           => 'ASC',
									'name'            => 'authors'
						);
						$author = get_term_by( 'slug', get_query_var( 'authors' ), 'authors' );
						if ( $author ) {
							$author_args['selected'] = $author->term_id;
						}
						wp_dropdown_categories( $author_args );
					?>

Anyone could help? Thank you :)

z6tanker on "using $get with gallery"

$
0
0

I want to use php's '$get' with a wordpress gallery so when a user clicks on a product on the site (http://studioanise.com take a look ;P) it brings them to a page that displays the image description that u can set and a larger version of the image. I know how to do this via hard code but i would like to be able to update the images easily.
Thanks
z

pkarjala on "Translating the Audio player interface in WP Core"

$
0
0

I've been trying to find where I can get access to translate the overlay text for the Audio Player in WordPress 4.1.1.

I you have an audio element hosted locally and load it using the [audio] shortcode, it puts an audio player in the browser. If you click on and drag the time bar, an overlay pops up with the following text:

"Use Left/Right Arrow keys to advance one second, Up/Down arrows to advance ten seconds"

I want to translate this text into another language for my site usage. However, the phrase does not appear when I generate a .PO file using Poedit on the site. It looks like this text might be housed inside of the .js file that runs the audio player.

Where can I go about finding this, and changing it manually? Or is there a way to generate a translation using the normal workflow of a .PO to .MO file?

artistbendavis on "Make $_SERVER['QUERY_STRING'] specify more than one query string"

$
0
0

my current code is this:

<?php
if ($_SERVER['QUERY_STRING']== "attachment_id=144")
{echo do_shortcode('[gallery ids="144,143,133,126,127,125,132,130,128"]');
}
else{echo do_shortcode('[gallery ids="243,247,250,249,245,241,246,248,244"]');}
?>

Basically how do i make it say if query string = "attachment_id=144" or "attachment_id143" or "attachment_id etc." do this. The code I have works for that one particular attachment but I can't figure out how to write in more than one.

hwtech on "config file defined value used in a shortcoe"

$
0
0

say I define an environment variable in wp-config
define('PHOTOBASE_URL', 'http://somedomain.com/photos');.

how can I access that variable in a html shortcode (say using shortcoder)

The idea is this case is to use it in an img tag so that the user only enters their photo filename as a parameter and the shortcode creates the full URL.

I suppose I could access it via php in the short code like this
<?php $url = PHOTOBASE_URL ?>

then in some html
<img src="<?= $url ?>%%filename%%" >

but is does the shortcode api have a way to identify/parse these in the html maybe using some special delimiters?

I've done this in a static site generator, Hugo, that supports shortcodes but there is an easy syntax for accessing site object variables in the hmtl.

lbrlbo on "Extract Last 5 Comments from the DB"

$
0
0

I need to Extract Last 5 Comments from the DB with the below style:

<Post Title> (x) <Last Comment of the Story>
--------------------------------------------
<Post Title> (x) <Last Comment of the Story>
--------------------------------------------
<Post Title> (x) <Last Comment of the Story>
--------------------------------------------
<Post Title> (x) <Last Comment of the Story>
--------------------------------------------
<Post Title> (x) <Last Comment of the Story>
--------------------------------------------

(x) - Number of Comments for the Story
<Post Title> - Name of the Post
<Last Comment of the Story> - Last comment to the above Story
Image: Sample
Please provide me a PHP code to accomplish this.

Thanks


Corneliatt on "My startpage loops twice"

$
0
0

Hi!
I'm going crazy here right now. I have a problem with my start loop, that wants to show the content twice. Is there anyone that knows why this problem occurs?

Here's my code:

<!--<div class="spacer"></div>
<div class="content transparent">
<div class="content-inner">
 <h1><strong>Header</strong></h1>
</div></div>-->

 <?php if (in_category('sticky')) { ?>
    <div class="content transparent splash"><?php the_post_thumbnail( 'full', array( 'class' => 'hundred-width' ) ); ?>
    <div class="intro"><h1><strong><?php the_title(); ?></strong></h1>
    <h2><?php the_field('ingress'); ?></h2>
    <?php the_content(); ?></div></div>

<?php } else {?>

<article id="post-<?php the_ID(); ?>">
<div class="content-inner transparent animatedParent animateOnce data-appear-top-offset='30'">
<div class="two-column-left-img animated fadeInDownShort go">
	<?php
		// Post thumbnail.
		the_post_thumbnail( 'large', array( 'class' => 'hundred-width' ) );
	?>
    </div>
    <div class="two-column-right animated fadeInUpShort go">
    <h1><?php the_title(); ?></h1>

    <p><?php the_excerpt(); ?></p>

<a class="button orange" href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">Läs mer</a>
<?php } ?>
</li>
</ul>
</div>
    </div>
    </div>

  <div class="content transparent">
<div class="content-inner front animatedParent data-sequence='500'">
 <?php
 $counter = 1;
 $new_query = new WP_Query(array('post_type' => 'my_content'));
while ($new_query->have_posts()) : $new_query->the_post();
?>
<div class="four-column-front transparent animated fadeInUpShort go data-id='<?php echo $counter?>'">
<div style="height: 250px; position: relative;">
<?php the_post_thumbnail( 'large', array( 'class' => 'hundred-width' ) ); ?></div>
<a href="<?php the_permalink(); ?>"><h4>Test<br>
<?php the_title(); ?></h4></a></div>
<?php
$counter++;
endwhile;
wp_reset_query();?>
<div class="clear"></div>
  </div>
</div>

    </article>

<div class="clear"></div>

<div class="content"><div class="content-inner">
<div class="three-column front-box l-grey animated fadeInUpShort go">
<img class="sub-bg" src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/sub-menu/three_column_img.jpg" alt="FAQ" />
<a class="button orange">FAQ</a></div>
<div class="three-column front-box l-grey animated fadeInUpShort go">
<img class="sub-bg" src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/sub-menu/three_column_img.jpg" alt="Frågor & svar" />
<a class="button orange">Test?</a></div>
<div class="three-column front-box l-grey animated fadeInUpShort go">
<img class="sub-bg" src="<?php echo esc_url( get_template_directory_uri() ); ?>/images/sub-menu/three_column_img.jpg" alt="Frågor & svar" />
<a class="button orange">Test</a></div>
</div></div>

<?php $new_query = new WP_Query(array('post_type' => 'faq', 'orderby' => 'rand', 'showposts' => '1'));
while ($new_query->have_posts()) : $new_query->the_post(); ?>

<div class="content faq orange">
<div class="content-inner">
<div class="two-column-left animated fadeInLeftShort go"><h2><?php the_title(); ?></h2></div>

<div class="two-column-right animated fadeInRightShort go"><?php the_content(); ?></div>
<div class="clear"></div>

<a href="/web/faq/" class="button l-grey">Läs FAQ</a></h2>
</div>
</div>
<?php endwhile;
wp_reset_query();?>

<?php

$new_query = new WP_Query(array('post_type' => 'quotes', 'orderby' => 'rand', 'showposts' => '1'));
while ($new_query->have_posts()) : $new_query->the_post();

$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>

<div class="parallax-fullwidth animatedParent" data-parallax="scroll" data-speed="0.5" data-image-src="<?php echo $url; ?>" data-natural-width="1500" data-natural-height="1000" data-position="0px 20px">
<div class="content-inner">

<div class="two-column-left"><h3><?php the_content(); ?></h3>
<p><?php the_title(); ?></p>
<a href="/web/quotes/" class="button orange">Quotes</a></h2>
</div>
<div class="clear"></div>
</div>
</div>
<?php endwhile;
wp_reset_query();?>

   <!--<?php
			/* translators: %s: Name of current post */
			the_content( sprintf(
				__( 'Continue reading %s', 'betavivo' ),
				the_title( '<span class="screen-reader-text">', '</span>', false )
			) );

			wp_link_pages( array(
				'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'betavivo' ) . '</span>',
				'after'       => '</div>',
				'link_before' => '<span>',
				'link_after'  => '</span>',
				'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'betavivo' ) . ' </span>%',
				'separator'   => '<span class="screen-reader-text">, </span>',
			) );
		?>  -->

	<!--<?php
		// Author bio.
		if ( is_single() && get_the_author_meta( 'description' ) ) :
			get_template_part( 'author-bio' );
		endif;
	?>-->

	<section class="entry-footer">
		<!--<?php betavivo_entry_meta(); ?> -->

		<?php edit_post_link( __( 'Redigera produkt →', 'betavivo' ), '<span class="edit-link">', '</span>' ); ?>
	</section><!-- .entry-footer -->
    </div><!-- .entry-content -->
    </div>

</article><!-- #post-## -->
<?php wp_reset_postdata(); ?>

Thank you soo much for the help!

zimbu555 on "Hiding user name discovery"

$
0
0

Checking my sites security on wprecon.com resulted in my users valid usernames being shown.

User Enumeration is possible by querying the author parameter and cycling through user id's /?author=1

Is there a way to hide this information?

pedgarcia on "Add URI sufix to all permalinks in a specific theme"

$
0
0

I've a website that uses a multi-theme plugin, filtered by the URL string:

http://www.vintageisthenewold.com/cia/

It works fine, but my problem is that the post links displayed on that page, for example:

http://www.vintageisthenewold.com/ultima-iv-remastered-source-code-on-github

if clicked on, it will show the main theme instead, since the URL does't have "cia" in it.

My solution for the problem is to add a parameter to all permalinks displayed by the secondary theme "cia", like this:

http://www.vintageisthenewold.com/ultima-iv-remastered-source-code-on-github/?ciatheme=1

I managed to hack the code in page-content.php and post-single.php in order to accomplish that, but I wonder if there is a more elegant and efficient way to do that: Some hook that will add a parameter to all permalinks displayed by this theme.

Any ideas?

Thanks

Paulo

lbrlbo on "Need to display share button option to share the post when hover over the post"

$
0
0

I need to display share button option to share the post when we hover over the post in the main page.

I have listed the post one by one as a list in the main page. I need to display the post share option (Share to FB, Twitter, Google Plus) when I hover over the post, When I lost focus on it it will automatically hides. If we click on a share button it need to share via the selected Social Network.

Is this possible, If yes please post a code for this. Image attached. Image

Thanks

mradnanox on "problem of WP_Query wp_pagenavi"

$
0
0

hi I have a problem with the request,
the code :

<?php
$my_query = new WP_Query( array( 'orderby' => 'comment_count', 'ignore_sticky_posts' => 1, 'paged' => get_query_var('paged') ) );

while ( $my_query->have_posts() ) : $my_query->the_post(); ?>

<section class="SectionCat">
<a href="<?php the_permalink();?>">
  <h2 class="H2Cat"><?php echo the_title();?></h2>
<?php the_post_thumbnail("thumb_cat");?>

<article class="ArticlesDetails">
  <p><?php echo excerpt(310);?></p>
  <div class="btn">Plus +</div>
</article>
</a>
</section>

<?php endwhile;
wp_pagenavi( array( 'query' => $my_query ) );
wp_reset_postdata();	// avoid errors further down the page
?>

Links appear fine, but when I click, it doesn't pass to the next page.

frastlin on "update_user_meta is not working"

$
0
0

Hello,
I am trying to update user data for the current logged-in user. I have the following function in my functions.php file:

function profile_func($atts){
//set $user as the current logged in user
$user = wp_get_current_user();

//check if there was a submition on this page before with the correct values
if(isset($_POST['submited_user_data']) && wp_verify_nonce($_POST['user_nonce'], 'user-data')){
//The below line is the one that doesn't work and it doesn't even show anything to say the function ran!
echo "The result is: " . update_user_meta($user->ID, 'display_name', $_POST['username']);

//The below line checks the current values and the submitted data.
echo $user->display_name . " Submited " . $_POST['username'] . "!";
}

//Now we load the form that has default values of the current user data.
?>
<form method="post" action="#">
<label for="username">What you would like to be called: </label>
<input id="username" type="text" name="username" value="<?php echo $user->display_name;?>" >
<label for="email">Your email address: </label>
<input id="email" name="email" type="email" value="<?php echo $user->user_email;?>">
<input name="submited_user_data" type="hidden">
<input type="hidden" name="user_nonce" value="<?php echo wp_create_nonce('user-data');?>">
<input type="submit" name="user_update" value="Update your info">
</form>
<?php
}
//This is so I add the short-code [profile] to the body of any post and it will load this.
add_shortcode('profile', 'profile_func');

All the values seem to be correct when I run it, but nothing changes! The function doesn't even return! Does anyone know why?

amcnaughton99 on "Unifying access to posts and their meta data"

$
0
0

I wrote some code to simplify working with WordPress posts and metadata. Here's the traditional WordPress way of dealing with a post and its meta data

$post = get_post(id);
 $meta1 = get_post_meta($id, 'meta1', true);
 $meta2 = get_post_meta($id, 'meta2', true);
 if($meta1 == $meta2)
     update_post_meta($id, 'meta3', 'value');
 $post->post_title = 'something new';
 wp_update_post($post);

That's a lot of ugly code. Here's the new way:

$post = new Post($id);
 if($post->meta1 == $post->meta2)
     $post->meta3 = 'value';
 $post->post_title = 'something new';
 $post->save();

Hope this is useful for someone. You can grab the code from https://github.com/amcnaughton/UnifiedPostInterface

Allan


Please Add Screenshots on "How to add placeholder text in a metabox?"

$
0
0
  1. I have a function that adds some placeholder text into the text only post content test area - it works great!
  2. I have added a function that allows me to move my post edit post content test area like other metaboxes (I assume it sort of removes it and re-adds it?) - it works great!

But, now the placeholder text in the new content text area doesn't appear.

How would I add the placeholder text into my 'new' post edit content textarea?

Placeholder function

add_filter('the_editor','wpse57907_add_placeholder');
function wpse57907_add_placeholder( $html ){
    $html = preg_replace('/<textarea/', '<textarea placeholder="my place holder text" ', $html);
    return $html;
}

Move editor function
// move editor on post edit page

add_action( 'add_meta_boxes', 'action_add_meta_boxes', 0 );
function action_add_meta_boxes() {
	global $_wp_post_type_features;
	if (isset($_wp_post_type_features['post']['editor']) && $_wp_post_type_features['post']['editor']) {
		unset($_wp_post_type_features['post']['editor']);
		add_meta_box(
			'description_section',
			__('Description'),
			'inner_custom_box',
			'post', 'normal', 'high'
		);
	}
	if (isset($_wp_post_type_features['page']['editor']) && $_wp_post_type_features['page']['editor']) {
		unset($_wp_post_type_features['page']['editor']);
		add_meta_box(
			'description_sectionid',
			__('Description'),
			'inner_custom_box',
			'page', 'normal', 'high'
		);
	}
}
function inner_custom_box( $post ) {
	the_editor($post->post_content);
}

GTHvidsten on "Showing a Thickbox (tb_show) does nothing"

$
0
0

I'm trying to add a media uploader to a widget/plugin and I'm at the stage where I need to add a picture from the media library (or upload a new one).

I added some javascript and added an event to a button in the plugin. This event gets fired (because the alert is displayed), but the thickbox does not show up.

Here's the JS code:

jQuery(document).ready(function() {
    jQuery('.upload_image_button').click(function() {
        alert('This alert is displayed');
        tb_show('Upload a Image', 'media-upload.php&type=image&TB_iframe=true', false);
        return false;
    });
});

And it is being included like this to be dependent on thickbox and media upload:

wp_enqueue_script('my_upload_script', get_template_directory_uri() . '/js/script.js', array('jquery', 'thickbox', 'media-upload'));

Why isn't the Thickbox displayed?

Charles Mabe on "Converting jQuery to something functions.php can use."

$
0
0

Hiya. I'm trying to follow a simple jQuery tutorial, but WordPress doesn't seem to understand jQuery in its most natural form and I need help.

I don't know jQuery and I'm trying to follow this tutorial: http://spoiledmilk.com/blog/sticky-sidebar/ to create a sticky sidebar on my blog design.

I do not know jQuery, but I have been reading about and failing to implement custom jQuery in WordPress for years; so please do not try to teach me jQuery. Instead, please tell me how to convert the jQuery I find to something WordPress can use. I still think that kind of lesson will sustain itself for me in the long term. After all I've studied, just replacing $ with jQuery just hasn't been enough to get things working! :P

Thanks.

amrinz on "Cleaner Bootstrap Gallery Shortcode"

$
0
0

Hi,

I create my own gallery shortcode using bootstrap 3 layout.
I want to share it, but also need more cleaner way since I just modify some code I found to create this shortcode.

The code consist of 3 functions:

/* Bootstap Gallery
 * Usage:
 * [btgalleryStart class='for first row only - leave empty for else']
 *		[btgallery-item col="4" src="image url" alt=""]
 *		[btgallery-item col="4" src="image url" alt=""]
 *		[btgallery-item col="4" src="image url" alt=""]
 * [btgalleryEnd]
 */
function lmd_btGalleryTop($atts, $content = null) {
   extract(shortcode_atts(array(
    'bg_class' => 'btgallery'
   ), $atts));
   return '<div class="row btgallery '.$bg_class.'">';
}
add_shortcode("btgalleryStart", "lmd_btGalleryTop");

function lmd_btGalleryBottom() {
   return '</div>';
}
add_shortcode("btgalleryEnd", "lmd_btGalleryBottom");

function lmd_btGalleryItem($atts, $content = null) {
   extract(shortcode_atts(array(
    'col' => 4,
	'src' => '',
	'alt' => ''
   ), $atts));
   return '<div class="col-md-'.$col.'"><img src="'.$src.'" class="img-responsive" /></div>';
}
add_shortcode("btgalleryItem", "lmd_btGalleryItem");

and the usage:

[btgalleryStart]
[btgalleryItem src="https://amrinz.files.wordpress.com/2015/04/gili-trawangan-island.jpg" col=4 alt="just example"]
[btgalleryItem src="https://amrinz.files.wordpres.com/2015/04/gili-trawangan-island.jpg" col=4 alt="just example"]
[btgalleryItem src="https://amrinz.files.wordpress.com/2015/04/gili-trawangan-island.jpg" col=4 alt="just example"]
[btgalleryEnd]

Its working but I think there is another way to join those functions and make it more efficient. Help me to make it look like this:

[btgallery class="myClass" col=2]
  [btgalleryItem src="" alt=""]
  [btgalleryItem src="" alt=""]
[/btgallery]

Thanks for your help

dgcov on "Invoking a callback to display metaboxes"

$
0
0

I am customising a post type:

add_action( 'init', 'register_team_sheet' );
function register_team_sheet(){
  $labels = array(...);
  $args = array(...);
  register_post_type( 'team_list_event', $args );
}

I have defined my metaboxes

function team_list_add_meta_box(){
  add_meta_box('team_list_event','Team Event fields','team_event_show_box', 'post');
}
add_action('admin_menu','team_list_add_meta_box');

And defined my callback:

function team_event_show_box(){
  echo '<input type="hidden" name="team_list_meta_box_nonce" value="', wp_create_nonce(basename(__FILE__)), '" />';
  $box_fields=array(...);
  foreach($box_fields as $field){
  ... render field...
}

But my callback never gets called and the metaboxes are never rendered.

This is understandable because I haven't linked the register_team_sheet() function to the callback.

The register_team_sheet function is visible in the Dashboard and can be invoked, but the metabox fields are not drawn.

How do I go about making sure that the callback is called when the register_team_sheet post type is selected?

Many thanks,

Dave

Viewing all 8245 articles
Browse latest View live




Latest Images