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

AJ Troxell on "Translation function calls must NOT contain PHP variables"

$
0
0

I am newer to WP plugin development and extensive Theme development. I am using and altering a theme options sample from ThemeShaper. My problem is localization and the structure of the theme-options.php file.

I know that this is improper: esc_attr_e( $options[$input['Input']] );

But I know not how to restructure it so that it is proper, but figured it would be something like this: esc_attr_e( _n('%d', '%d', $options[$input["Input"]], 'white'), $options[$input["Input"]] ); yet all this does is fill my fields with a value of %d.

Can anyone lend me a hand on how to make this proper?


hugoleveille on "Photo external link with shadowbox"

$
0
0

Hi

I have a few photo on my blog that are set to open an external link. Unfortunatly, there is no option when setting the external link in the admin panel to tell it to open in inside a shadowbox plugin. I took a look where that link is saved and it looks like it is inside the database.

Is there a way to do what I want?

kinging on "plugin development: how to add code to the head tags and the body tags"

$
0
0

Hi, i'm developing plugin, and i need to insert some HTML code between the <head> and </head> tags, and also some PHP&HTML&jQuery code between the <body> and the </body> tags(no metter where). how can i do this? can you give me code example?

creativewild on "Make plugin options available in front-end for registered users"

$
0
0

Hi all,

I have tried to search but i was unable to find or i used the wrong keywords for that.

Here's my Question:

Is there a way to make the backend option os a plugin to be available in the front-end site so the users don't have to go to wp-admin to add/change things.
The plugin in question is http://wordpress.org/plugins/gw2-chars/, I was able to change the permission to allow the registered uses to see it (instead of the default that just allowed for editor or above to use it).

Any help would be great appreciated.

Thanks

dediwi on "more in category description"

$
0
0

Hello,
i have a very long category description and i would like to have showen just one paragraph the rest should be hide under a more button, if i click more i would like to open the text down like a dropdown.
Someone know if a plugin or function like that exist allready

here we have it for example http://www.modamarcas.com/ropa-mujer/
if you click read more you have that what i want

cfetr on "question about get_post_meta()"

$
0
0

Greetings everyone,

I am a new developer to WordPress. I have been browsing tutorials and the forums about adding metaboxes to posts. I can do all that successfully so thanks to everyone who asks questions and replies with answers.

To my question, in tutorials I see everyone using this:
$meta = get_post_meta($post->ID)
and then accessing their fields like so:
$meta['my_custom_field']

This does not work for me. $meta['my_custom_field'] will always be an array and I will need to use $meta['my_custom_field'][0]. Can anyone explain to me why this is happening? Are the tutorials just out of date?

Thanks for your help

bagwis on "Redirect non post author to homepage"

$
0
0

Hello,

I am currently working to a project wherein I need to have a function that will redirect the current user if he/she tries to view the custom post type which he/she doesn't own. The reason is that my client requires me to make this singular page to be accessible only to the admin and post author since it contains personal information.

I've searched for some ideas but I haven't found any so I referred to the codex and found this template_redirect. So here is my current code

function check_the_author(){
    global $current_user;
	$user_id = get_current_user_id();
	$post_author = get_the_author_meta('ID');
	if( is_singular('my_post_type') && $user_id != $post_author ){
		wp_redirect( home_url() );
		exit();
	}
}
do_action( 'template_directory', 'check_the_author' );

Unfortunately, even if the post author is viewing his own post, it still being redirected. So I tried to interchange the code and make it similar to this

function check_the_author(){
    global $current_user;
	$user_id = get_current_user_id();
	$post_author = get_the_author_meta('ID');
	if( is_singular('my_post_type') && $user_id == $post_author ){

	}
	else{
		wp_redirect( home_url() );
		exit();
	}
}
do_action( 'template_directory', 'check_the_author' );

but the result for this second code is simply nothing, I mean if a user tries to view others' posts he can access it and doesn't get redirected. I already posted here to ask for some assistance cause I've been working with this for more or less 3 hours now. Thank you, by the way the website is still on my localhost so I can't provide a link.

leelaprasadr on "My wordpress site is showing Levitra Viagra ad only in mobile browser"


THE MOLITOR on "Publish scheduled/future posts in 3.5"

$
0
0

Hi there,

I'm using the following code in my functions.php file that sets posts with a future publish date to the "published" status (instead of "scheduled").

Everything worked perfect until updating to WordPress 3.5. Does anybody know why?...

function setup_future_hook() {
 // Replace native future_post function with replacement
 remove_action('future_post', '_future_post_hook');
 add_action('future_post', 'publish_future_post_now');
}

function publish_future_post_now($id) {
 // Set new post's post_status to "publish" rather than "future."
 wp_publish_post($id);
}

add_action('init', 'setup_future_hook');

awhite2 on "When I call information saved in an options page only one letter shows up."

$
0
0

I've created an options page and I'm now trying to call one of the inputs in my theme. It's currently only showing the first letter, though.

The input section for the field is

add_settings_field(
	    'station_name',
	    'Station Name',
	    array($this, 'create_an_id_field'),
	    'station-setting-admin',
	    'setting_section_id'
	);
    }

    public function check_ID($input){
        if(!empty($input['station_name'])){
	    $mid = $input['station_name'];			

	}else{
	    $mid = '';
	}
	return $mid;
    }

    public function print_section_info(){
	print 'Enter your settings below:';
    }

    public function create_an_id_field(){
        ?><input type="text" id="stationname" name="array_key[station_name]" value="<?=get_option('station_name');?>" />

and the I'm referencing it by:

<?php $station_info = get_option('array_key');?>

			    <h2><a href="mystation.com" title="Station"><?php echo $station_info['station_name']; ?></a>

I tested by inputing WXYZ in my options page and it saves. But, then I only get the letter W on the link.

jemsz on "Custom Fields PHP NOOB!"

$
0
0

Gretings all.

Right now i use wordpress and in my post i can add a Video by entering the Youtube address into a Custom field called "video_url" and then it outputs the video on my site wich works easy, here it is:

<div class="video">

      <html><center>
<?php
$meta_value = get_post_meta($post->ID, 'video_url', true);
if($meta_value){
$url = parse_url($meta_value);
$id = 0;
if($url['host'] == 'youtu.be'){$id = ltrim($url['path'],'/');}
else if(strpos($url['path'],'embed') == 1){$id = end(explode('/',$url['path']));}
else{parse_str($url['query']);$id = $v;}
echo '<p><iframe width="540" height="355" frameborder="1" allowfullscreen="true"  src="http://www.youtube.com/embed/'.$id.
'?version=3&theme=light&fs=1&rel=0&cc_load_policy=1&iv_load_policy=1&modestbranding=1" type="application/x-shockwave-flash" allowScriptAccess="always" allowfullscreen="true" width="600" height="355">
</iframe></p>';
}

?>

</div>

However i am tring to add this Modification here in wich adding the video link custom field will also bring back the youtube video title and descripiton,

<?php
$video_id = ’48J_DIZBNyE’;
$video_info = simplexml_load_file(‘http://gdata.youtube.com/feeds/api/videos/’.$video_id.’?v=1′);
echo $video_info->title . ‘<hr>’; // title
echo $video_info->content; // description
?>

Could anyone please help me implement the bottom code with the top piece of code !!

Mucg respect

Thanks

Shovan Sargunam on "Display Specific category and number of post"

$
0
0

Hi,

Currently I have blogs page which pulls content from these category - blog, news and video.

<?php $recent = new WP_Query(); ?>
<?php $recent->query('cat=4,cat=15,cat=159'); ?>

<?php while($recent->have_posts()) : $recent->the_post(); ?>
	<div class="row <?php if ( $post->ID == $wp_query->post->ID ) { echo ' first-post yellow-higlight'; } else {} ?> blog-post">

I would like to limit number of post shown on that page to 5.

I believe the code I have written need to be modified or updated.

Any suggestion would help

Ottens on "Open posts as accordion on front page"

$
0
0

What I'm hoping to accomplish: similar to the "Latest News" area in the new Reuters site.

My front page currently displays the title and excerpt of a post, along with a thumbnail. I want to keep that basic structure, but have the main post appear, accordion-style, when readers click either the title or the thumbnail, or the "block" for that matter, as is the case on the Reuters site, both of which now link to the single post.

I've been trying different plugins and reading through similar topics, but so far what I've found either doesn't quite give me what I want (like an expanded "Read More" functionality; most of my articles don't have a "Read More" link in them) or I can't make sense of the coding. I can manage CSS, PHP and HTML, but I'm a Javascript-novice. I'd rather avoid Javascript altogether, in fact. But I wouldn't consider myself a professional so be gentle.

Can it be done? If so, how?

Thanks for your help.

Matteo Legittimo on "Please Help! Remove base URL from Taxonomy and Post Type"

$
0
0

Hi,
im getting crazy, and cant find a solution!

This is my code:

/*Register Alloggio Content Type*/
add_action( 'init', 'maremoto_easy_room_content_type' );

function maremoto_easy_room_content_type() {
	$labels = array(
		'name'               => _x( 'Alloggio', 'post type general name' ),
		'singular_name'      => _x( 'Alloggio', 'post type singular name' ),
		'add_new'            => _x( 'Aggiungi Nuovo', 'Alloggio' ),
		'add_new_item'       => __( 'Aggiungi Nuovo Alloggio' ),
		'edit_item'          => __( 'Edit Alloggio' ),
		'new_item'           => __( 'Nuovo Alloggio' ),
		'all_items'          => __( 'Tutti gli Alloggi' ),
		'view_item'          => __( 'Guarda Alloggio' ),
		'search_items'       => __( 'Cerca Alloggi' ),
		'not_found'          => __( 'Nessun appartamento trovato' ),
		'not_found_in_trash' => __( 'Nessun appartamento trovato nel Cestino' ),
		'parent_item_colon'  => '',
		'menu_name'          => 'Alloggio'
	);
	$args = array(
		'labels'        => $labels,
		'description'   => 'Holds our products and product specific data',
		'public'        => true,
		'menu_position' => 5,
		'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt'),
		'has_archive'   => true,

	);
	register_post_type( 'easy-room', $args );
}
//////////////////////////////////////

add_action( 'init', 'maremoto_taxonomie_category_easy_room', 0 );
function maremoto_taxonomie_category_easy_room() {
	$labels = array(
		'name'              => _x( 'Categorie Alloggio', 'taxonomy general name' ),
		'singular_name'     => _x( 'Categoria Alloggio', 'taxonomy singular name' ),
		'search_items'      => __( 'Cerca Categoria Alloggio' ),
		'all_items'         => __( 'Tutte le Categorie' ),
		'parent_item'       => __( 'Parent Categoria Alloggio' ),
		'parent_item_colon' => __( 'Parent Categoria Alloggio:' ),
		'edit_item'         => __( 'Edit Categoria Alloggio' ),
		'update_item'       => __( 'Update Categoria Alloggio' ),
		'add_new_item'      => __( 'Aggiungi Nuova Categoria' ),
		'new_item_name'     => __( 'Nuova Categoria Alloggio' ),
		'menu_name'         => __( 'Categorie Alloggio' ),
	);
	$args = array(
		'labels' => $labels,
		'hierarchical' => true,
		'show_admin_column' => true,
	);
	register_taxonomy( 'easy-room_category', 'easy-room', $args );
}
//////////////////////////////////////

hou can i remove base url from my Custom post type and My taxonomy?

From:
http://www.domain.com/easy-room_category/asia/
http://www.domain.com/easy-room/kuta-villa-roma/

to:
http://www.domain.com/asia/
http://www.domain.com/kuta-villa-roma/

thanks a lot!
Matteo

TLis on "Can't Connect to Second MySQL DB"

$
0
0

I need to connect to a second database.

The following works fine on my local installation:
$newdb= new wpdb("DBUserName","Password","DatabaseName","HostName");

That immediately connects me with my non-WordPress database.

I'm not getting a connection using this code on the live site though, even though I've changed all the variables to correspond to the webhost's parameters (and I've checked against the wp-config file, too -- I'm using the same hostname that shows in the config file, so I know I've got that right).

WordPress isn't giving me anything to go on: the only error message I can get it to display has no actual message (as shown below):

WordPress database error: []

I haven't included a sitelink, since this is for a secured intranet (and I can't leave the non-functioning page visible to access for the users anyway until I can resolve this problem).


palobarini on "How to Change the Default Tab in Media Manage"

$
0
0

Hello! I wanted to have only Insert from URL option in media manager and nothing else. Neither Library, nor Upload Files be as simple as possible.
I followed the instructions from here: http://sumtips.com/2012/12/add-remove-tab-wordpress-3-5-media-upload-page.html and removed everything that I didn't need.

It worked well but, the problem is that when I open media manager, the default screen is still the one you get from the Upload Files (the one you get with the "Drop files anywhere to upload" and "Select Files", "Insert into post" buttons). Although Upload Files is nowhere to be seen and the "Insert into post" button is disabled, every time I open the media manager I get this tab. Is it possible to change the default tab from Upload Files to Insert from URL tab, so every time I open the media manager I get there instead from the Upload Files? Or to a custom created tab in media manager like the one you can create from the link above.

In sort, how can I change the default tab from the media manager?

Thank you.

erikstainsby on "Show Custom Field data on All Pages table listing"

$
0
0

So I have a need to include the values stored in a couple of custom fields as columns on the table listing All Pages. These show ancilliary statuses describing a workflow. (yawn)

The documentation that I've come across all assumes that either the fields are part of a custom page type, or are part of the core table field set. Neither of these is true in this instance.

Has anyone got an idea how I might hook the list table's building routines based on postmeta data?

TIA,
Erik

Alex4red on "WP Admin Bar CSS origin"

$
0
0

Does anyone know where I can remove wordpress' call to the adminbar.css, admin-bar.min.css files.

I've already established a large css file that contributes to this, no need for multiple http responses.

[No bumping. If it's that urgent, consider hiring someone.]

zurreal on "How to start the loop at a specific post? (implementing Show More Posts button)"

$
0
0

Background:
At work I've inherited a theme (Salient by ThemeNectar - http://themeforest.net/item/salient-responsive-portfolio-blog-theme/4363266) that was purchased by a colleague and has since been hacked to pieces. While I would much prefer to recode everything from scratch, that just isn't feasible at this time.

Currently, we use the custom portfolio section to display our large (and growing) catalog of work in images on the front page. We've cut down the image file size as much as possible, but the mansonry script is still pretty slow when it has to style 120+ post thumbnails on the main page.

To solve this, I am currently implementing an infinite scroll feature, or at the very least a "show more posts" button at the bottom. The pagination is all wonky, so the all the easy ways don't seem to work (like the Infinite-Scroll plugin).

Admittedly, I still have lots to learn when it comes to PHP and JavaScript, but I know enough to get by.

The Question:
What I would like to do is run the regular loop, display around 40 posts and a "Show More" button (though infinite scroll would be nice). Then, upon clicking the button or reaching the bottom of the page, run an AJAX script to call a php function that will display the next batch of 40 posts.

Aside from loading posts into an array and remembering the index of the array, how else can I do this? I would really like to find a way to just run the loop again to load more posts but have it start up again where I left off after the previous loop. Is it possible to start the loop at a given post? What functions should I be looking at for this?

deputy963 on "Add shortcodes,text, and htm to a category and its' children"

$
0
0

Hello all,

I would like to add some shortcodes, html, and text to the bottom of all posts in a category and all children of that category(about 15 of 40 categories). The problem is my PHP skills are lacking (to say the least).
example cat 1 <-added to this one
- example cat2 <-added to this one
- example cat3 <-added to this one
-- example cat3a <-added to this one
example cat4 <-NOT added to this one

I figure the best way to accomplish this is to add a filter to the functions.php using something along the lines of

add_filter('the_content', 'custom_category_text');

with a statement like

if (in_cat(28) || post_is_in_descendant_category(28)){$content =  $content . $custom_category_text;
}
return $content;
}

So the whole thing would look something like this:

add_filter('the_content', 'custom_category_text');
function custom_category_text($content){
global $post;
$custom_category_text = 

if (in_cat(28) || post_is_in_descendant_category(28)){$content =  $content . $custom_category_text;
}
return $content;
}

So, does anyone think this will work?

If so, then my question becomes "How do I format the PHP in "$custom_category_text =" so that the shortcodes, html, and text all work?"

Viewing all 8245 articles
Browse latest View live




Latest Images