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

swedish boy on "date_i18n and timestamps"

$
0
0

This was a bit puzzling to me, but date_i18n doesn't adjust to local timezone as one would think. If you set your timezone in wp-admin to GMT+1 this is what happens in the following 2 examples.

Let's say GMT time is 17:05.

echo date_i18n('H:i');

// Will output current hours and minutes of local timezone
//Result: 18:05

However if you give this function a custom timestamp or time():

echo date_i18n('H:i', time());
// Output: 17:05

// $some_timestamp is set to time()-3600;
echo date_i18n('H:i', $some_timestamp);
// Output: 16:05

In both last examples date_i18n outputs GMT time.

The fix is to do add the following to your timestamp:

$timestamp += get_option( 'gmt_offset' ) * 3600;
echo date_i18n('H:i', $timestamp );

Almost a bug if you ask me.


jay patel on "plugin conflict with adminlogout"

$
0
0

i have created a new plugin for my wp blog , but when the new plugin is activated and i try to log out, wp shows a blank screen and don't let me log out. when i deactivated my new plugin i successfully logged out .can anyone help me..?
note: on localhost its working properly.

Takius on "Add class to a anchor"

$
0
0

Hello,

I want to add class for all my anchor, but i dont have any clue how to do it.

More precisely, i want this :
<a name="RefDeLAncre"></a>
become this:
<a class="Ancre" name="RefDeLAncre"></a>

Thanks for your help.
Takius.

tonyzeoli on "Exclude categories and set primary category for post on homepage"

$
0
0

Hi,

We're trying to solve an issue for a client project.

The business rules are the that the editor can publish a post to multiple categories, but only display one of those categories in a flag on the homepage and limit the homepage to only publishing one of those categories in the loop.

For example, I may have a post that I categorize as News, Sports, Video, I want the post to show up in the loop under News, Sports, or Video, but for home, I might only want the category of Sports to display in the category flag layered over the featured image.

I understand there is an Exclude Categories function in the WordPress API, but I'm not sure that will work.

Do we build a meta box tool in the admin sidebar that says "Hide Categories from Home" after they are selected and appear in the Category meta box then we can AJAX them into the HIde Categories from Home Metabox.

Will something like that work? Is there anything out there that can handle this?

You can see the issue at work here: http://onebeat.dswdev.net/. You can see that there is a category flag on the homepage that is supposed to be clickable to return all posts in that category, but it's not yet clickable. You can see from the menu that a post could live in three categories.

Any help on how to solve this would be appreciated.

hopetommola on "Custom Fields in Quick Edit View"

$
0
0

https://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column

I want to activate "Custom Fields" options in quick edit view, much like this page shows how to show the "sticky" column.

Any ideas or advice? I tried deconstructing the sticky example, but I'm not doing it correctly.

An administrative employee needs to use the Custom Field "Published Date" to enter the date that a draft post was published, while retaining the original creation date, and not having to go into the Edit Post screen.

Please advise. Any assistance greatly appreciated.

Doodlebee on "AJAX search for adding links/media"

$
0
0

Hello all :)

I'm trying to figure out what WordPress is using in the admin area for the AJAX stuff: a) when you click the "media" button the popup window shows , and b) within the window, you can start typing the name of the image you want, and via AJAX, it'll show results as you type.

I'm curious as to what two functions pull this off?

I'm working on a plugin where I need to have a popup window with AJAX search, and instead of using some external stuff (since this is inly happening with the admin area), I just wanted to hijack what WordPress uses to pull this off, and tie into it for the plugin I'm writing.

I've been searching like crazy for the info, but so far I'm coming up empty. Can anyone point me in the right direction?

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!

chuffORG2000 on "embed HTML5 interactive animation in Category"

$
0
0

Hello, I've done a ton of searching on this and no luck, plus I'm much more of a graphic designer than web designer, so please forgive my noob-ish understanding of code. I can get it to work in Pages and Posts (see here: http://technologyvcc.com/?p=47) using the below code, but in my "Room Signs" Category it just displays the code (see here: http://technologyvcc.com/?cat=4), which I entered into the categories Description field. I'm doing all this in a child theme, and have created a category.php for it with this code:

<?php

	get_header();

	if(have_posts()) :

?>

		<div id="post">

			<div class=" post-list-content">

				<h1><?php echo single_cat_title('', false); ?></h1>

			</div>

		</div>
<?php if (is_category('Room Signs')) : ?>
<[iframe src="http://technologyvcc.com/GOOGLE_DESIGNER_TEST/GOOGLE-DESIGNER-TEST.html" width="1200" height="600"] shortcode>
<p>This is the text to describe Room Signs</p>
<?php elseif (is_category('Kiosks')) : ?>
<p>This is the text to describe Kiosks</p>
<?php else : ?>
<p>This is some generic text to describe all other category pages,
I could be left blank</p>
<?php endif; ?>
<?php

		get_template_part('content', 'postlist');

	else :

		get_template_part('content', 'none');

	endif;

	get_footer();

?>

This is the code that works on Posts and Pages:

[iframe src="http://technologyvcc.com/GOOGLE_DESIGNER_TEST/GOOGLE-DESIGNER-TEST.html" width="1200" height="600"] shortcode

I've also added the below to a new functions.php in my child theme:

<?php

add_shortcode('iframe', 'ag_iframe');
function add_iframe($initArray) {
$initArray['extended_valid_elements'] = "iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width]";
return $initArray;
}
add_filter('tiny_mce_before_init', 'add_iframe');

Any help is greatly appreciated, thanks!


idledae on "Simple Feed Alias, Help!"

$
0
0

How do you create a simple URL alias to an existing feed URL.

Ex.
I have this URL:
http://my.example.org/category/something/feed

I want the same feed to work at this URL:
http://my.example.org/somethingelse/feed

I've tried using Apache rewrite rules and don't seem to be getting the desired effect.

without creating a redirect. Any assistance would be greatly appreciated!

edow on "Remove text field from comment form"

$
0
0

Hi,

I would like to remove the text field from the comment form. The idea is that users can vote if they like the post or not. The like/unlike option must be done with radio buttons in a custom field (that would be the next problem).

But first: How can I remove the text field? I don't want it hidden, but entirely removed. What is the best practice for this? I can't find a decent solution.

Hopefully anyone can help me with this.

gahcarving on "How to change Virtue Mobile style.css"

$
0
0

I have tried a number of things that didn't work,
tried '@media handheld { {color: green; }}' in the style.css
Am i going down the wrong road?

Looking forward to some thoughts.

A31 on "Nested Select Menu"

$
0
0

Hi,
I am really struggling to get a second dropdown / select box to be automatically populated and I hope someone here can help me find my mistake.

Before moving to Wordpress, I have been using the example by W3Schools but now in wordpress, I can't seem to get it working.

My Code is as follows:

<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","Fin_GetAllocation.php?q="+str,true);
xmlhttp.send();
}
</script>
<form>
	<select name="sel_CostCentre" id="sel_CostCentre" onchange="showUser(this.value)">
		<option value=0>Please Select Cost Centre: <?php echo $CostCentreDescriptionOptions; ?>
	</select>
    <select name="Sel" id="txtHint"></select>
</form>

then the code in the file "Fin_GetAllocation.php" is as follows:

<?php
	global $wpdb;

	$q=$_GET["q"];

	$SQL_Query01 = ("SELECT * FROM wp_allocations_tbl WHERE CostCentreDescription = '$q'");
	$SQL_Results01 = $wpdb->get_results($SQL_Query01);

	foreach($SQL_Results01 as $myResult01)
		{
			$AccountDescription = $myResult01->AccountDescription; //Field in DB
			$AccountDescriptionOptions.="<option value='$AccountDescription'>" . $AccountDescription . "</option>";
		}

So my first dropdown / select box works perfectly, but I can't seem to get the second box to populate.

Can you please help?

marathonmilk on "Display slideshow, if not display featured image."

$
0
0

Hi there

I'm using a slideshow plugin which generates a slideshow and outputs a shortcode to use it in the theme or post. I've added a custom field to posts where that shortcode can go.

What I'd like is for the theme to check if there's a short code there, and if there is to display it, if not, check it there's a featured image for the post and display that, and if there's no short code and no featured image to do nothing. Does that make sense?

Having a bit of trouble with it, so if anyone's able to help that would be much appreciated.

Thanks!
Mark

Note: reposting this as I got the original forum wrong.

2005casemore on "Installing Installation Code For A Web Form"

$
0
0

I have a web form to put on my site and I have the HTML code to install it. How do I do this

netbie on "Tags and Categories Hack help"

$
0
0

I am using this code for display the Tags inside one category

<?php
//get category name
$catname = get_category(get_query_var('cat'))->name;
//get all tags in this category
query_posts("category_name=$catname");
if (have_posts()) : while (have_posts()) : the_post();
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
//Get Tag ID
$all_tags_arr[] = $tag -> term_id;
}
}
endwhile; endif;
//remove duplicates
$tags_arr = array_unique($all_tags_arr);
?>

I have 2 questions:

1) How can I display these tags as DROPDOWN instead of Tags Clouds ?

2) How can I do the same but inverse: I mean display the Categories inside One tag, as DROPDOWN.

Thanks in advance for your help.


ShootingStar83 on "child-of [x] category in CURRENT post"

$
0
0

I found this code to show sub categories of [x] category and I like it, I just need to make it working as "Show sub-categories of [x] category IN CURRENT POST" because I'm going to paste this code in a widget inside posts only.

<?php
$subcategories = get_categories('&child_of=4&hide_empty'); // List subcategories of category '4' (even the ones with no posts in them)
echo '<ul>';
foreach ($subcategories as $subcategory) {
  echo sprintf('<li><a href="%s">%s</a></li>', get_category_link($subcategory->term_id), apply_filters('get_term', $subcategory->name));
}
echo '</ul>';
?>

What is the code that will apply this code to the post the visitor is reading?

Appreciate your help in advance.

Thank you

Torpedox on "Plugin-Development"

$
0
0

Hello,

I am developing a plugin for Wordpress. It's my second one and I am facing the following issue:

I added a menu for my plugin in Wordpress-Backend. I have also added an Icon to this menu. Everything works fine, but the next to the menu, a small Symbol is shown. See screenshot below:

<img src="http://img5.fotos-hochladen.net/uploads/snap20ewkq15dma.png" border="0">
http://img5.fotos-hochladen.net/uploads/snap20ewkq15dma.png

What does this mean?
It is shown in Internet Explorer. Firefox doesn't show it.
I used "DebugBar" for debugging, but no error is shown...

Thank you

jacob0601 on "Related Posts by Multiple Tags"

$
0
0

I was curious if was possible to display related posts by multiple tags.

The site I am working on has about 5 tags per post. Most posts have 1 or 2 tags in common. The related posts I'd like to show have 3-5 tags in common. I would link the site, but this is all locally developed with mamp.

So, I'd like the related posts to function by looking for posts with the most number of tags in common and display them in descending order.

Let's say I display 3 related posts: relatedpost1 would have 4 tags in common, relatedpost2 would have 3 in common and relatedpost3 would have 1 in common.
Is it even possible to do this?

Right now I am messing around with two ways of displaying the posts but they arent functioning as I'd like:

The first method (code here: http://codepad.org/K9UGSYuc) just shows posts with ANY tags in common.

The second method (code here:http://codepad.org/ZGrzMXIE) just shows posts with the first tag in common.

I'm either getting pretty random posts displaying (since most of my posts have at least 1 tag in common) or (for some posts) getting no related posts (since their common tags are tag 4 or 5).

Any help would be greatly appreciated.

ibetthisispublic on "Show only post from selected category"

$
0
0

Hi.

I have searched for about 10 hours now and even though I've found some category template hacks out there, the ones that kind of work still don't fix the problem.

The same problem/behaviour goes for standard posts as for Woocommerce product listings: when a base category is selected, WP shows all posts, even those from subcategories.

Even if I somehow manage to code a template that would list the desired products, the product counter would still be wrong because that's part of a different php file that's loaded before the template.

So I am looking for a hack/filter that would alter the core WP code so that when I list posts from a certain category, none from subcategories are returned. This is the behaviour I want for all posts on the site.

Thanks for reading.

chrismichaels84 on "Custom Taxonomy public or private?"

$
0
0

I have created a number of custom post types (stories, authors, reviews, and news). Stories acts as a master or primary for the others. I have also created a custom taxonomy for "stories" called "stories_master" that is hierarchical like categories. I then, attached that taxonomy to my other post types. All is fantastic.

What I am trying to do is make the "stories_master" taxonomy visible in the post area (for new or edit reviews, authors, etc), but NOT visible under the administration menus. I don't want users to be able to add categories in the taxonomy. The plugin creates the categories. Does that make sense? So far, I can get one or the other to work.

Here is the relevant code:

/** Here is where I create the taxonomy and attach it to the master "stories" custom post type **/

add_action( 'init', function () {

// Create the slug
$sanatized = "stories_master";

// Add new taxonomy, make it hierarchical (like categories)
$labels = array(
    //with all my labels
);

$args = array(
	'labels' => $labels,
	'public' => true,
	'show_in_nav_menus' => false,
	'show_ui' => true,
	'show_tagcloud' => false,
	'show_admin_column' => true,
	'hierarchical' => true,

	'rewrite' => true,
	'query_var' => true
    );

register_taxonomy( $sanatized, array( 'stories' ), $args );
register_taxonomy_for_object_type( $sanatized, 'stories' );

/** When I create the other post types "authors, reviews, etc", I add this taxonomy like so: **/
'taxonomies'	    => array( 'post_tag', 'stories_master' )

Is what I am trying to do even possible? Is there a work around? I guess I could just manually remove the link from the menus.

Viewing all 8245 articles
Browse latest View live




Latest Images