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

brianhre on "in_category condition not working"

$
0
0

Hello. I`m trying to display a label with specific text for products that belong to two categories (Green and Oolong). All other categories will display the same text. I am having trouble getting this to work correctly.

<?php if ( in_category('Green') ) { ?>

    <label><?php _e( 'Quantity - 150 G', 'yit' ) ?></label>

<?php } elseif ( in_category('Oolong') ) { ?>

    <label><?php _e( 'Quantity - 150 G', 'yit' ) ?></label>

<?php } else { ?>

<label><?php _e( 'Quantity', 'yit' ) ?></label>

<?php } ?>

Any help would be appreciated.


Linesofcode on "Clear cookie of posts password protected"

$
0
0

I'm sorry if this isn't the right section of the forum to publish this topic.

I'd like to create a page just to reset cookie.
I tried to create a page: unset.php, I put the page inside the wp-content\themes\mytheme\, with this code:

<?php setcookie("wp-postpass_", "", time()-3600);
unset($_COOKIE["wp-postpass_"]); ?>

Then, I would like to call this way:

<form method="post" action="unset.php">
  <input type="submit" value="logout"/>
<form>

Or even
<a href="/unset.php">Logout</a>

But it's not working. Any ideias? Thanks!

waverider1 on "Update posted date without changing order"

$
0
0

I like the idea of having the date updated to only show the "modified" (or last update} date when I update a post, but when I update the timestamp manually (in post edit), it puts the post first on my blog. Is there a way to only display the modified date but keep the pages in the original order?

StephanWizcorp on "User data encryption"

$
0
0

Hi there!

I'm using WordPress for a website project where there're some requirements about privacy respect. Thus, I would to encrypt my data user using a AES algorithm. As I'm developing a custom plugin, I have no problem to encrypt my user's sensitive data, because I provide the page that contains the registration for. But the problem is when it comes to display and modifiy these information in the core WordPress' backend. I couldn't find out where and how I could do that... I've looked for this information in the Internet for hours without being able to find it.
I've found this page https://code.google.com/p/wordpress-aes/ where a guy has developed a repo on Google Code, doing (almost) the stuff I want to do, and he tells that he sent a mail to people at WordPress for merging his code into WordPess' core. As that guy did not do a plugin or whatever, it lets me think that it's not possible to modify the reads and writes done from and to the database, from the backend...
Could some one help me about this issue?
Thanks in advance.

Enzo on "Can't edit the CSS of the Navbar, through an option in Customize"

$
0
0

Hello everyone,

Thanks for taking the time to read this post. Now, I am aware this question has been asked quite a number of times, but the results I found always ended up in directly editing the theme's CSS. I'm afraid this isn't an option for me.

See, I'm editing the function.php and header.php to create a colour picking option in Customize Site - Color.

Everything seems to work just dandy. The content, widgets, sidebars, backgrounds, everything. But for some peculiar reason the navigation bar seems to elude this succesful streak. And frankly, it's kind of bugging me since I can't seem to figure it out.

// THEME COLOUR CUSTOMIZATION
add_filter( 'customize_register', 'hg_customize_register' );
function hg_customize_register($wp_customize)
{
  $colors = array();

  // Main Content
    $colors[] = array( 'slug'=>'content_link_color', 'default' => '#88C34B', 'label' => __('Content Link Color', 'Toppen' ) );
	$colors[] = array( 'slug'=>'content_text_color', 'default' => '#000000', 'label' => __( 'Content Text Color', 'Toppen' ) );

  // Side Bar
	$colors[] = array( 'slug'=>'content_sidebar_color', 'default' => '#ffffff', 'label' => __( 'Sidebar Header Color', 'Toppen' ) );
    $colors[] = array( 'slug'=>'sidebar_bg_color', 'default' => '#ffffff', 'label' => __( 'Sidebar Background Color', 'Toppen' ) );
	$colors[] = array( 'slug'=>'sidebar_content_color', 'default' => '#000000', 'label' => __( 'sidebar Content Color', 'Toppen' ) );
	$colors[] = array( 'slug'=>'sidebar_bg2_color', 'default' => '#ffffff', 'label' => __( 'Sidebar Header Background Color', 'Toppen' ) );

  // Navigatie Bar
	$colors[] = array( 'slug'=>'nav_bg_color', 'default' => '#000000', 'label' => __( 'Navigatie Background Color', 'Toppen' ) );

  // Extra
	$colors[] = array( 'slug'=>'button_bg_color', 'default' => '#000000', 'label' => __( 'Search Button Color', 'Toppen') );  

  foreach($colors as $color)
  {
    // SETTINGS
    $wp_customize->add_setting( $color['slug'], array( 'default' => $color['default'], 'type' => 'option', 'capability' => 'edit_theme_options' ));

    // CONTROLS
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, $color['slug'], array( 'label' => $color['label'], 'section' => 'colors', 'settings' => $color['slug'] )));
  }
}

And in the header, I'm using:

<?php
	wp_head(); 

	// Main Content
	$content_link_color = get_option('content_link_color');
	$content_background_color = get_option('content_background_color');
	$content_text_color = get_option('content_text_color');

	// Side Bar
	$content_sidebar_color = get_option('content_sidebar_color');
	$sidebar_text_color = get_option('sidebar_text_color');
	$sidebar_bg_color = get_option('sidebar_bg_color');
	$sidebar_content_color = get_option('sidebar_content_color');
	$sidebar_bg2_color = get_option('sidebar_bg2_color');

	// Navigatie Bar
	$nav_bg_color = get_option('nav_bg_color');

	// Extra
	$button_bg_color = get_option('button_bg_color');

	?>

	<style>
	<!-- Main Content -->
	body a { color:  <?php echo $content_link_color; ?>; }
	.container:before { background-color:  <?php echo $content_background_color; ?>; }
	body { color:  <?php echo $content_text_color; ?>; }	

	<!-- Side Bar -->
	#sidebar h3 { color:  <?php echo $content_sidebar_color; ?>; }
	#sidebar h3 { color:  <?php echo $content_sidebar_color; ?>; }
	.widget ul { background-color:  <?php echo $sidebar_bg_color; ?>; }
	.page-content a { color:  <?php echo $sidebar_content_color; ?>; }
	#sidebar h3 { background-color:  <?php echo $sidebar_bg2_color; ?>; }

	<!-- Navigatie Bar -->
	.navbar {
    background-color: <?php echo $nav_bg_color; ?>;
    border-bottom: <?php echo $nav_bg_color; ?>;
}

Now, as you can see, there are three parts responsible for the navigation bar. I'll copy them so you won't have to read that monster sized code if you don't want to:

In Functions.php we've got:
$colors[] = array( 'slug'=>'nav_bg_color', 'default' => '#000000', 'label' => __( 'Navigatie Background Color', 'Toppen' ) );

And in Header we got both:
$nav_bg_color = get_option('nav_bg_color');

and

.navbar {
background-color: <?php echo $nav_bg_color; ?>;
border-bottom: <?php echo $nav_bg_color; ?>;

Now, you're probably smirking, saying to yourselves "This is child's play, how can you not get this?" And honestly, it probably is easy. That was what I was thinking at the very least when I started this. After all, with Firebug (in Firefox) I managed to deduce that by editing the colors directly under, you got it, navbar, it changed, therefore concluding that it was indeed '.navbar' that I needed.

And yet it doesn't seem to work. So if anyone has any suggestions, maybe a wake up hammer or something to point out something I've been missing or a correction, I'd fully appreciate it.

Also, if this isn't the right place to ask this kind of question, sorry to y'all, I actually made the mistake earlier when I posted this question on WordPress.com. As you can imagine, yes, wrong place, didn't know that myself. So feel free to blow this topic up with an Alien Blaster or, at least, move it if it's wrong. xD

With friendly regards,
E. D.

YCressant on "WordPress 3.6 Javascript code remains after template_redirect"

$
0
0

The purpose is to produce an ical feed from a plugin

With a simple template_redirect, it was possible until WordPress 3.5.2

After migration to WordPress 3.6, some javascript code remains before de content like this

<!--[if IE 8]>
    <script type="text/javascript">
        (function($) {
            var imgs, i, w;
            var imgs = document.getElementsByTagName( 'img' );
            maxwidth = 0.98 * $( '.entry-content' ).width();
            for( i = 0; i < imgs.length; i++ ) {
                w = imgs[i].getAttribute( 'width' );
                if ( w > maxwidth ) {
                    imgs[i].removeAttribute( 'width' );
                    imgs[i].removeAttribute( 'height' );
                }
            }
        })(jQuery);
    </script>
    <![endif]-->

<script type="text/javascript">
jQuery(document).ready(function($) {
	$("#rotator").cycle({
	    fx: 'cover',
	    timeout: 12000,
	    speed: 2000,
	    pause: 1,
	    fit: 1
	});
});
</script>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

RavanH on "Shortcode inline with text always wrapped in P tags?"

$
0
0

Hi all,

I've search the forums and internet for this issue but only found very old (2+ years) threads about this. And some 'solutions' or rather work-arounds that all have their own downside.

In the codex on http://codex.wordpress.org/Shortcode_API under Output, I read:

wpautop recognizes shortcode syntax and will attempt not to wrap p or br tags around shortcodes that stand alone on a line by themselves. Shortcodes intended for use in this manner should ensure that the output is wrapped in an appropriate block tag such as <p> or <div>.

That part 'that stand alone on a line by themselves' is key. What if a user does not put that shortcode on a single line but places it at the beginning of a new paragraph line? In that case, the output, even when it is a DIV, gets wrapped inside the P tag together with the text that follows.

Another example: The user put two shortcodes (can even be different kinds) with a space between them together on one single line ? Then again, there are P tags thrown around. But funnily NOT when there is no space between the shortcodes...

The only reasonable solution I found is an old trick:

//move wpautop filter to AFTER shortcode is processed
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 99);
add_filter( 'the_content', 'shortcode_unautop', 100);

which does seem still effective but it will affect ALL other shortcodes, I suppose...

Is there really no cleaner way?

kitcorsa on "Direct Required - Flooring Site - E-commerce/booking"

$
0
0

Im looking for a bit of advice or direction here,

Im looking to make a site for my brother who is specialist flooring expert who can supply fit and repair floors. What i'm after doing is creating a restoration site for him which explains how he resorted and repairs old wood floors and preserves them. this part is straight forward enough etc, the wall i'm hitting and getting stuck on is an online quote / booking system which could have a payment (paypal option)

This service is fairly straight forward as my brother charges a set price per square meter, so what i'm trying to do is create a form where the customer can enter the width and length of there room, and get a quote, then send a booking email to my brother with the same information for my brother to contact them and arrange the appointment to go round, inspect and perform the job.

The next problem is what if the customer has more than one room?? is there a way of adding a room 2 room 3 etc etc etc if required.

We have also though about taking an online deposit via paypal for say 10%, we would not be able to take the full amount as the customer may enter the wrong size trying to get a cheaper job done, or over changed by not measuring correctly. Deposit first and final payment on completion would be better if possible.

Could anyone please point me in the right direction please. Thank you


gokhanefendi on "[Plugin: All in one seo pack] Custom Title Format"

$
0
0

Hi everyone,
i want to change post title like this "%Cat1% %Cat2% - %post-title%"

Cat1 is a subcategory name in MainCategory1
Cat2 is an another subcategory name in MainCategory2

Example:

Page Title: Medicalpark Hospital
Cat1: London (Choosen by Cities, main cat.)
Cat2: Health (Choosen by Sectors, main cat.)

Output: London Health - Medicalpark Hospital

How can i change the title using the plugin or other way?

blzalewski on "Settings Manipulation from UNIX Terminal"

$
0
0

Hi, I'm using WP CLI and I'm trying to set up an automated installation to tweak WordPress perfectly.

I have a few questions but they all pretty much boil down to:

How do you modify WordPress settings from the UNIX terminal using WP CLI?

Example: I have Yoast SEO installed and I'd like to disable the "Will you allow me to collect information?" popup that comes up right after you first activate the plugin.

Thanks

cerstrand_mace on "the_title as category in query"

$
0
0

My question is rather simple. Is it possible to use the title of the current page as the category in a query array?

I guess it would look somewhat like this but I haven't got it to work:

<?php
		// The Query
			query_posts(array( 

				'post_type' => 'product',
				'cat' => the_title()

         ) );
?>

mak1wp on "Conditional script enqueue"

$
0
0

Hi,

I'm having some trouble enqueuing isotope/masonry/infinite scroll scripts.

I'm using wpquery for creating various blog and portfolio post layouts via a page builder. Theres various layout styles/columns, each one duplicated for isotope filter, masonry, fit rows, masonry + infinite scroll or fit rows + infinite scroll.

I've tried to create one big script containing all these isotope options using various div classes on the layout templates, but with no success. (masonry responds slow and infinite scroll just doesn't work)

I can get the desired effect working by linking the script directly on the loop template used (and splitting up the isotope jquery functions), but I dont think this is recommended.

the templates I'm referring to are not wordpress page templates, they are the post layout templates I've created, located in mytheme/loop-templates/portfolio or mytheme/loop-tempaltes/blog. So using the conditional if is page (page) will not work.

does anybody know how to condition the script load for a custom page location like the one in my setup?

Any feedback on this would be a really great help.

Many thanks!

patrick_here on "Running add_role() one time only"

$
0
0

Since add_role() needs to be run one time only to add a new role, what's the best way to run it only one time?

I don't want to generate a new database call every time a visitor comes to the site (or views a particular page).

Is there a function or file that is run/invoked only once when a theme/plugin is initially installed? If so I suppose I'd like to put it in there so that whenever I install a new site this new role will be aded on initial install and on existing sites it would seem that I could simply disable/re-enable the plugin/theme to activate the new role one time only.

coldpumpkin on "Change generated HTML code from "Add Media" button"

$
0
0

Hello there.

When we're inserting an image to a post, by clicking the "Add Media" button, WordPress generates a certain code, being:

<a href="image_url"><img src="image_url" alt="image_name" width="image_width" height="image_height" class="image_class" /></a>

Question here is - how to change the way the code is generated? What if I want to add attributes to the <a> tag? And what if I don't want some of those attributes of the <img> tag?

Thanks in advance for your answers!

anespa on "How to customize user creation"

$
0
0

Dear friends,
I need to customize User creation in WP

1. In current situation after user creation we need to check email and then login , but I need to login on same time to my account with that password (means redirect on same process itself).

2. I need to remove some fields on user creation(like more info) and add some fields (like age,weight,height etc..)

Please advise a method for same .

Thanks,
Anes


zenox11 on "How can I add an offset parameter to this block of codes"

$
0
0

I want to display the second most recent post but I'm kinda new to wordpress... help please, anybody.

$args = array('posts_per_page' => $options['posts12number'], 'category__in' =>  $options['politics']);
        $the_query = new WP_Query($args);
        ?>

[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

WazzaJB on "WP_Query with tax_query not returning all posts"

$
0
0

Hi there,

When using the "tax_query" parameter in my arguments, I am not getting all the posts returned - but despite this "found_posts" is returning the correct amount. This ONLY happens when using the "tax_query" parameter, the "s" parameter alone works perfectly.

Here are the arguments I am passing http://pastebin.com/0Ak98EHe

Any help with this would be greatly appreciated,
Thanks,
WazzaJB

jp2112 on "Best practice for updating plugin when only version compatibility changes"

$
0
0

I feel like I've asked this question before, apologies in advance.

Some of my plugins are listed as compatible with version 3.6. Now that version 3.6.1 is out, I would like to update them to confirm that my plugins are compatible. However, I don't have any actual code updates. Would it be considered spamming to check-in only the readme.txt for each plugin to reflect the updated compatibility?

Thx

miyarakira on "Shortcode as parameter to another shortcode"

$
0
0

I'd like to use a shortcode as a parameter to pass to another shortcode:

[google_map address="[content field='address']"]

However, this outputs a blank map plus this string: "]

I've looked in both shortcodes to see if do_shortcode() on the parameter would solve it, but no luck. Would anybody have an idea how to achieve this?

brochris on "Working on my first plugin"

$
0
0

I'm trying to create my first plugin. The bit that I'm working on now is supposed to read the post title and create an image with that text in it. But for some reason it's not saving the image. Here's what I have:

// Get the post title from the post
$post_data = get_post($post->ID, ARRAY_A);
$post_slug = $post_data['post_name'];
$post_title = get_the_title( $post_id );

// Generate the image
$new_img = imagecreatetruecolor( 200, 80 );
$background = imagecolorallocate( $new_img, 200, 200, 200 );
$text_color = imagecolorallocate( $new_img, 150, 100, 100 );
$line_color = imagecolorallocate( $new_img, 128, 255, 0 );
imagestring( $new_img, 4, 30, 25, "$post_title", $text_color );
imagesetthickness ( $new_featured_img, 5 );
imageline( $new_featured_img, 30, 45, 165, 45, $line_color );

// Save the image
$upload_dir = wp_upload_dir();
$upload_dir_path = $upload_dir['baseurl'];
imagejpeg( $new_featured_img, "$upload_dir_path/$post_slug.jpg" );
imagecolordeallocate( $new_featured_img, $line_color );
imagecolordeallocate( $new_featured_img, $text_color );
imagecolordeallocate( $new_featured_img, $background );
}

Here are the warnings it gives me:

Warning: imagejpeg() [function.imagejpeg]: Unable to open 'http://pastorhuff.com/wp-content/uploads/what-happens-in-a-fallen-world.jpg' for writing: No such file or directory in /home/pastor/public_html/wp-content/plugins/auto-featured-image-from-title/auto-featured-image-from-title.php on line 35

Warning: Cannot modify header information - headers already sent by (output started at /home/pastor/public_html/wp-content/plugins/auto-featured-image-from-title/auto-featured-image-from-title.php:35) in /home/pastor/public_html/wp-admin/post.php on line 222

Warning: Cannot modify header information - headers already sent by (output started at /home/pastor/public_html/wp-content/plugins/auto-featured-image-from-title/auto-featured-image-from-title.php:35) in /home/pastor/public_html/wp-includes/pluggable.php on line 875

Would greatly appreciate any guidance. Thanks.

Viewing all 8245 articles
Browse latest View live




Latest Images