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

joosep on "Add color palette to post edit."

$
0
0

Howdy people,

I dont know where to start with this thing.

I want to have a color palette when I am adding or editing a post and later get that color and use it in the post.

Any pointers ?

Thanks in advance.


pixel016 on "wp_generate_attachment_metadata does not work"

$
0
0
$filename = get_user_meta($userID, 'image_profil',true);

        $wp_filetype = wp_check_filetype(basename($filename), null );
        $wp_upload_dir = wp_upload_dir();
        $attachment = array(
           'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
           'post_mime_type' => $wp_filetype['type'],
           'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ),
           'post_content' => '',
           'post_status' => 'inherit'
        );
        $attach_id = wp_insert_attachment( $attachment, $filename);
        require_once( ABSPATH . 'wp-admin/includes/image.php' );
        $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
        wp_update_attachment_metadata( $attach_id, $attach_data );
        set_post_thumbnail( $post_id, $attach_id );

Why the $attach_data return an empty array ? :(

coinpixels on "Change Font Size Depending on Content Lenght"

$
0
0

Hey,

If the_content lenght is more than so many words I could like to change the font size.

Is this possible? I would normally give it an attempt but have no idea how to accomplish this.

davisshaver on "One feed, two queries – problem with scheduled posts"

$
0
0

I have an RSS feed configured to show the 20 most recently modified posts. However, I'm facing an issue where posts scheduled far in advance do not get included in the feed, as they do not appear as recently modified.

Is there a way to modify a query to order by modified/published date while also giving both the same weight?

Here's what the code looks like currently.

$args = array(
	'orderby'=> 'modified',
	'order' => 'DESC',
	'showposts' => '20',
	'post_type' => 'post',
	'post_status' => 'publish'
);
$posts = query_posts($args);

Piotr on "Dynamically adding forms and options"

$
0
0

I'm continuing my work on a Wordpress site that uses forum posts as content (more on this can be found here and here).

After creating news section which takes first post of every topic and turns it into a Wordpress post I need something more complicated - a section of articles. This requires taking the first post of a topic and appending the remaining posts to the first one - just like chapters in the article. And actually this is something that I've already achieved. I'm using a second query to get posts from a topic, and by using variables for topic IDs and post IDs I can even specify which posts will be imported and appended. The problem is I need to be able to add, edit or remove topics and posts IDs from the query. After using settings API in the news section I thought that it wouldn't be too difficult to use it here, but sadly it is. And this is where I need help.

What I need is an options page that will list all the topics and posts IDs, and let me add, edit or delete these settings and will update the list. I tried to use the settings API, to add a pair of forms every time an option is added, but I'm not even close to what I need. I'm not even sure if storing a multidimentional array ( article# => array( topic_id => 'value', posts_ids => 'values' ) ) as an option is a good idea. I'll be grateful for any ideas.

satrap on "Replacing the "Post" title with a universal custom text in in breadcrumbs?"

$
0
0

Hi everyone,

Let me explain what I mean...

Example:

Current setting:
Home > Make Money > How to Make 10 Dollars Fast: Ridiculously Easy Method!

Somehow changing what it shows as the title of the post so the title is not repeated twice.

So it would be something like this:
Home > Make Money > This Post

Where as "This Post" (or "You are Here", or any other custom text) is the text that shows for all post and page titles in the breadcrumbs instead of the actual titles.

I am using Twenty Thirteen WP theme if that makes any difference.

I m creating the breadcrumbs through the Yoast SEO plugin. But If there is a fix for this that requires manually doing it, I can disable it from Yoast setting and do it manually.

The site in question is http://moneypantry.com

Thanks in advance everyone.

lokust on "Sort comments by custom field (dropdown)"

$
0
0

Hi, I'd like to use a Wordpress page to enable customers to leave reviews (standard comments form with an additional custom field for user to select the product they'd like to review). They can also apply a star rating to their comment/review (using something like: Comment Rating Field Plugin). I'm fine with this part of the requirement, and would appreciate help/pointers on the following requirement:

Add a dropdown field to enable the users to sort comments/review by products.

Thanks,

Al

Vajrasar Goswami on "save_post not working"

$
0
0

In order to create (or update, whenever a post is updated) a unix-timestamp meta, I used following code to fire on save_post. I pasted this code in functions.php.

But I believe this is not working, as I can't access the related unix meta created by save_post in loop anywhere in a custom template.

Code -

function vg_update_timestamp( $post_id ) {

    $offerstartdate = get_post_meta($post_id, 'offer_cmb_offer_from_textdate', true); //not unix timestamp
    $offerenddate =  get_post_meta($post_id, 'offer_cmb_offer_till_textdate', true);  //not unix timestamp

    $timestamp_start = strtotime( $offerstartdate );
    $timestamp_end = strtotime( $offerenddate );

    update_post_meta($post_id, 'offer_cmb_offer_from_textdate_unix', $timestamp_start );
    update_post_meta($post_id, 'offer_cmb_offer_till_textdate_unix', $timestamp_end );
}
add_action( 'save_post', 'vg_update_timestamp' );

benutzerfreund on "Loading template twice - how to do it?"

$
0
0

I have a template that I'd like to use several times on a page. I use
include( get_stylesheet_directory() . '/ads.php');
and this works for the first instance. But on the second it doesn't. Apparently it is only possible to include it once. So I tried:
locate_template( array( 'ads.php' ), true, false );
But to no avail. And get_template_part doesn't do the trick either.

Which is the correct way to do it? (I want do use it in the Loop, to include a block of ads every 3rd post on my homepage.)

brosenblatt on "Customizing Post Titles to be a form"

$
0
0

We have a job board on our Wordpress site that utilizes a designated JOBS custom post type. I'd like it so that we could edit the title field to be a dropdown/text field of three different choices (Location) - (Job Title) - (Industry).

Does anyone know of a plugin to support this?

olyma on "Turning Off Open Sans for the 3.8 Dashboard"

$
0
0

I’m looking for a way to turn off the Open Sans font in the admin. I’m already using the code below to force the admin area to use a different font:

function betterfonts1() {
?>
<style type="text/css">
body {font-family: Times New Roman,Times;}
</style>
<?php
}
add_action( 'admin_head', 'betterfonts1' );

This works really well, but the Open Sans is still being called in the header. It looks like this in the header:

<link rel='stylesheet' id='open-sans-css' href='//fonts.googleapis.com/css?family=Open+Sans%3A300italic%2C400italic%2C600italic%2C300%2C400%2C600&subset=latin%2Clatin-ext&ver=3.8' type='text/css' media='all' />

For efficiency I’d like to have the call be turned off completely. I’ve tried the following bit of code:

function removeopensans() {
	wp_deregister_style( 'open-sans' );
}
add_action( 'admin_enqueue_scripts', 'removeopensans' );

And this works, but it completely removes the stylesheet so there is zero styling for all of the admin. I’ve also fiddled with the core file script-loader.php by commenting out line 634:

// $open_sans_font_url = "//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets";

Commenting out this bit of the core file does the trick. It turns off the open sans font call in the header but keeps the general admin styling. Is there a way to turn off the open sans font in the admin without fiddling with core files?

belinde on "Detect begin and end of an automatic update"

$
0
0

I'm developing a plugin that manage filesystem's write permission (it's called AutoCHMOD). The problem is that when the protection is enabled no one can write on the disk (you can choose some directory to remain writeable, obviously) so automatic updates won't run. My idea was to detect the very beginning of the update, re-enable writings, let the update run and re-disable writings afterward. I've searched technical documentation about the update process but I wasn't able to find it, so I've searched through the code and I've found the class WP_Automatic_Updater, method run(), that seems to be the core. After some check there is an update_option(), then it try to do the update, then there's a delete_option().
My idea was to use actions 'update_option_auto_updater.lock' and 'delete_option_auto_updater.lock': I thought the first will be called BEFORE write permission check and new version availlability, and the last is called anyway there has been changes or not. The problem is that I've installed my plugin in some sites that haven't been upgraded from 3.8 to 3.8.1 yesterday, and today no one has been upgraded yet. I've checked also the homepages to eventually fire the cron event.
I don't know how to try further: any suggestion? How can I detect the begin and the end of an automatic update?

harknell on "Paginating Archive using "weekly" type"

$
0
0

Is there a way within WordPress to add a pagination "next" and "previous" links to an archive page set with the "weekly" type? I can't find any info on this anywhere, and adding the standard template pagination codes does not output the expected links to the page.

Is this a weird area WordPress doesn't really support? If so why have the "weekly" type at all?

alemieux on "Lightbox URL's not working"

$
0
0

I have a custom theme and I'm using a simple JavaScript Lightbox effect to display a modal with a list of links to some PDF files. Each item in the list can be added in the WP admin for that page.

The resulting modal displays correctly but the links do not work. The href has nothing in it. It looks like this:

<a href target="_blank">

I checked the code in the metaboxes.php file and it seems to be correct. Any idea what could be causing this?

truheart on "Change item order for +Add menu in the admin bar"

$
0
0

I hope the title makes sense. Basically I would like to know how to change the order of the items a user sees when he clicks on the "Add" button in the admin bar. For instance, say you have a couple of different post-types where a user can add a new post directly from the admin bar. How do you get it to display the post-types in the order you would like? The default post-type and media items are always on top and it would be great to be able to have control over this. Thanks guys.


loudrake on "Admin wp_check_browser_version"

$
0
0

Where is the list of browser versions that is being checked against to determine if a dashboard_browser_nag is shown?

javawpscript on "How to have a different favicon for each page"

$
0
0

What i would like is to have specific favion's on each page. I have currently got All in one favicon installed.

hovida on "WP_Query - Meta with Arrays"

$
0
0

Hey guys,

i try to work a little bit with meta_query on the pre_get_posts action and i have a little Problem.

I have a custom Post-Type "news". On the edit-page i had added a custom meta box. Here the user can select the visibility of the news. For example:
Metabox Screenshot

Options (postmeta and usermeta) will be stored as Array (serialized) in the metadata, like:
PMA - Postmeta
PMA - Usermeta

But how i can combine the meta-querys with Arrays?

add_action('pre_get_posts',						array($this, 'pre_get_posts'));

function pre_get_posts($query) {
			if($query->query_vars['post_type'] == 'news') {
				$user				= wp_get_current_user();
				$user_company		= get_user_meta($user->ID, '_user_company', true);
				$user_company		= empty($user_company) ? array() : (array) $user_company;
				$user_company[]		= 'all';
				$user_company[]		= 'front';

				$query->set('meta_query', (array(array(
					'key'		=> '_news_visibility',
					'value'		=> $user_company,
					'type'		=> 'array'
				))));
			}

			return $query;
		}

Data - The _news_visibility is an array. For example:
array( 'all', 1 )

_user_company from the userdata is an array like:
array( 1, 2 )

JayKayBe on "Import custom post table to wordpress and keeping IDs"

$
0
0

I am standing in front of a problem I can’t really see how to resolve. I am about to transfer a website which is written in PHP to wordpress. There’s really not much complicated about this but one thing. The website has near 30k posts which contain only a title and an image (much like e.g. 9gag). These posts are stored in a MySQL Database and the urls look something like this:
domain.com/parameter/id
with ID being the ID from the database. It is crucial to keep those urls on the new site for facebook likes/comments and Google search results. However those ids are for the most part incrementing by one each. On Wordpress each post I create has 4 consecutive IDs in the wp_posts table, this way blocking the IDs for the three next posts. As far as I am seeing it, the additional IDs are used for further data concerning the post (e.g. image attachements). However in the old database each entry had a value containing the path to the attached file. Is there any way to realize this the same way in a wp_posts table? To have a custom field with the image path that wordpress would recognize to show the image in the post? I am new to wordpress, so I am still trying to figure a lot of things out. If you need any further information please let me know. Please respect that for privacy reasons I can not give out the domain name and exact urls.

Best Regards, Jay

MagicFire on "Redirect (or rewrite) to main page without 404 error"

$
0
0

Hi,

I need to be able to keep wordpress on main page but also to keep the full requested URL (only for some special url).

Example:

http://www.mydomain.com/contant

would lead for wordpress to load main page like http://www.mydomain.com/ but it will keep the string parametr contact so I can move the user to the correct position on the main page via the JS.

And it will do only for 4 specific string parameters, otherwise it should lead to the home page without the parametr.
Is it possible in WP?

I need this for SEO usage. I have functional JS script that add this parametr to URL, but when user hit reload button, WP correctly says hat this URL is not found. And I need to get passed this and get to the script the string parametr.

Thank you for any advice.

Viewing all 8245 articles
Browse latest View live




Latest Images