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

Tim on "Secondary blog page using specific category"

$
0
0

My client wants a secondary blog on their site.
The simplest way to set this up would be installing a secondary wordpress installation, but this would require them to have a secondary login for this specific blog/installation.

I was thinking i could set up a specific category that would be displayed only on a specific page, so i did some googling.

I came across this article: http://tinyurl.com/qa4qsue
seems like exactly what i'm looking for.

I followed the instruction and inserted the specified code into functions.php and created the alternate single.php page as per instruction. so far so good.

What i don't understand is how to get the posts from this category to display on a specified page (separate from the normal posts page).

UPDATE:
Just discovered that the category in question is not being excluded from the normal blogroll/posts page, which was the point.


fanalejr on "Prevent other plugin meta-boxes from showing on my plugins' custom post type?"

$
0
0

Hey guys,
I hope this makes sense. I have a plugin that registers a custom post type. This custom post type only supports "title" and then has a few custom meta boxes added for specific content. This all works great, but if the user has other plugins installed that add metaboxes to post edit pages, those get added to my custom post type edit page as well and I'm hoping there is a way to prevent that from happening?

For example, one of the big ones is the Wordpress SEO plugin - adds a metabox, adds content to the publish box, and adds a slew of columns to the "view all" page. None of this is needed for my specific custom post type.

Any ideas? Is something like this possible?

jrcayal on "send mail or create restricted access user role? experts advice needed"

$
0
0

Hi there, i'm a complete newbie here, it's my first time on anything about Wordpress coding (php, wordpress itself) and i'm developing a plugin for a client that shows a weekly sales report for a store.
The thing is done, queries are coded and results shown in beautiful tables.
Now, the client (site administrator) asks me for one more thing. The store sells products from different producers so, for the sake of easier re-stockig management he wants either one of these features:
(1) the weekly report generates a file (csv, pdf, whatever) that is automatically sent by mail to each producer with his products sold list
(2) create a new role and user accounts for the producers so they can log in and check (and print/download) that same information, so they would only have acces to that specific plugin page.
the question:
what would be easier to do/code?
many thanks in advance!!

jeriksson on "Need some help pulling excerpt from post that doesn't have an excerpt."

$
0
0

Hi,

i'm trying to make my site add automatic information for facebook likes og:image og:Title and such.

can someone explain why this code doesn't work (everything works except the description part)

<?php if (is_single()) { ?>
<meta property="og:title" content="<?php the_title(); ?>"/>
<meta property="og:description" content="<?php $content = get_the_content(); $content = strip_tags($content); echo substr($content, 0, 100); ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>"/>
<?php $fb_image = wp_get_attachment_image_src(get_post_thumbnail_id( get_the_ID() ), 'thumbnail'); ?>
<?php if ($fb_image) : ?>
    <meta property="og:image" content="<?php echo $fb_image[0]; ?>" />
<?php endif; ?>
<meta property="og:type" content="<?php
    if (is_single() || is_page()) { echo "article"; } else { echo "website";} ?>"
/>
<meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>

 <?php } ?>

I'm using <?php $content = get_the_content(); $content = strip_tags($content); echo substr($content, 0, 100); ?> to pull the content and then strip everything beyond 100 characters, but it shows up as nothing in the html source

its also emtpy if i use <?php echo strip_tags(get_the_excerpt($post->ID)); ?> but that's probably because i've not created any excerpts, i'm not sure if excerpts are being automatically generated or if they have to be manually created by default, i'm guessing the second.

Any help on this would be appreciated.

efiga on "problem with http://genericstts.com/init.min.js"

agiuliano8 on "Permalinks"

$
0
0

Hello, I'd like to include %year% in my permalink structure, but I'd really like it if it could return just the last 2 digits of the year, rather than the full 4. I checked the permalinks help page, but didn't see any obvious solutions. Is this possible?

Thanks

mark-ter-s on "Post header works in Chrome button not in Firefox or IE"

$
0
0

Hi,
i hope somebody has the answer to the following problem,
my post headers are clickable links to the whole article.

but the "header link" is only working in chrome and not in internet explorer or firefox. when hovering over te link it also doesn't react as a link. but in Chrome it does.
Ik tried it on a different pc once in IE, it works sometimes

i hope somebody has the answer to this, cause it very frustrating

thanks in advance
http://Www.Toerroute.nl

mireillesan on "Add span to wp_list_categories"

$
0
0

I'd like to add a span tag to display categories.

How it is right now:
<li class="cat-item cat-item-7"><a href="#">category #1</a></li>

How I'd like it to be:
<li class="cat-item cat-item-7"><a href="#"><span>category #1</span></a></li>

Unlike the other threads I've read, I'd like to do this inside my function.php file through a filter.


quietthunderdesigns on "Adding additional category option for posts on homepage"

$
0
0

I'm working with a theme that allows for only two types of posts to be displayed on the frontpage - fresh (newest) and hot (most liked). I'd like to add another category specifically for homepage posting called "homepage".

In the front-page.php, I found these instances of fresh and hot:

<?php
                    /* if hot or new  */
                    if( isset( $_GET[ 'fp_type' ] ) ){
                        switch( $_GET[ 'fp_type' ] ){
                            case 'hot' : {
                                post::hot_posts();
                                break;
                            }
                            case 'news' : {
                                post::new_posts();
                                break;
                            }

                            default : {

                                if(is_user_logged_in() ){
                                    if( $_GET['fp_type'] == 'like' ){
                                        post::like();
                                        break;
                                    }
                                }
                                if( options::get_value( 'front_page' , 'type' ) == 'hot_posts' ){
                                    post::hot_posts();
                                }
                                if( options::get_value( 'front_page' , 'type' ) == 'new_posts' ){
                                    post::new_posts();
                                }
                                if( options::get_value( 'front_page' , 'type' ) == 'new_hot_posts' ){
                                    post::new_hot_posts();
                                }
                                break;
                            }
                        }
                    }else{
                        /* if not set params for hot or new */
                        if( options::get_value( 'front_page' , 'type' ) != 'page' ){
                            if( options::get_value( 'front_page' , 'type' ) == 'hot_posts' ){
                                post::hot_posts( false );
                            }
                            if( options::get_value( 'front_page' , 'type' ) == 'new_posts' ){
                                post::new_posts( false );
                            }
                            if( options::get_value( 'front_page' , 'type' ) == 'new_hot_posts' ){
                                post::new_hot_posts( false );
                            }
                            $post_id = 0;

Can I just add in extra lines replacing hot_posts with homepage_posts?

I'm new to php so any help is much appreciated - thanks!

Red Deer Web Design on "Checkbox validation"

$
0
0

Hey guys,

I have a list of checkboxes and am wanting to build in some kind of loop so I don't have to list every single checkbox. Currently I just have 2 to test with:

// Sanitize and validate input. Accepts an array, return a sanitized array.
	function lc_options_validate($input) {
		// Our first value is either 0 or 1
		$input['option1'] = ( isset($input['option1']) == 1 ? 1 : 0 );
		$input['option2'] = ( isset($input['option2']) == 1 ? 1 : 0 );

		return $input;
	}

I am drawing a blank, any ideas on how I can have this loop?
Thanks!

onurkinay on "check online user from username"

$
0
0

Helo WP Users,

My problem, check online user from username, like this

<?php

if($login == "user1"){

echo "user1 is login";
}
else{

echo "user1 isn't login";

}
?>

this $login, WordPress code which can be?

(Bad english because use Google translate :) )

peterk900 on "Prevent php scripts used in WP being run outside WP"

$
0
0

I have a custom page template which reveals php files for someone studying the page source. What code can I put at the start of this file to prevent someone trying to run the script outside Wordpress ?

For example in an Ajax script I have the line

if ( empty( $_REQUEST['action'] ) )
	die( '0' );

Someone trying to run this code directly just see a 0.

Thanks.

presis_carsten on "admin user automatically added"

$
0
0

For my company we maintain around 50 WordPress websites. Recent something strange has happened.

Almost every website had a new user with the username 'admin' with Adminstrator role, emailadress 'admin@localhost' and registration date '2010-03-01 11:06:24'. The password is a MD5 hash (no salt, like a normal WordPress password), example: 1c1df24bdf22b10fce4b2a5003bdbdfa

It seems it was something automated. Even a website protected with a .htpasswd had this 'admin' user.

Our webhoster says their system is not hacked. The plugins and themes that we use are from the official WordPress website.

Does anyone have an idea how did happened?

venenum11 on "Recent comments support only one post types?"

$
0
0

I'd like to display attachment, posts and page in recent comments widget.

So, in default-widgets.php

$comments = get_comments( apply_filters( 'widget_comments_args', array(
			'number'      => $number,
			'status'      => 'approve',
			'post_status' => 'publish'
		) ) );

And i have changed in:

$comments = get_comments( apply_filters( 'widget_comments_args', array(
			'number'      => $number,
			'post_status' => array( 'inherit', 'pubblish', ),
			'post_type' => array( 'attachment', 'post', 'page', ),
			'status'      => 'approve',
		) ) );

But it doesn't work.

Any suggest or possible solution?

littletanhouse on "[Plugin: WooCommerce]Add Learn More Button or Redirect Add to Cart Button."

$
0
0

Hello to all,

I wanted to know how I can add a button to my shop page using WooCommerce plugin. I want users/visitors to be able to go to the product page using a button on the shop page. I have the add to cart button. I would like to add a new button that would say "Learn More" have this button redirect to that products page. Or change the "Add to Cart" button to redirect to that products page.

If someone could please advise I would be very grateful.

Thank you for your time, Aaron M.


keirgarth on "2014 theme need to scale slider"

$
0
0

I am doing a class project and want to scale the slider to fit the images that I have chosen. I am not real familiar with wordpress so any advice would be great. Currently the slider is the full width of the site minus the sidebar and I would like it to be half width and shorter. Site is jcdesigns.us

sinemac on "Can widget use data array generated by a plugin?"

$
0
0

[mis-posted this in 'plugins' forum... reposting here... not sure how to delete the other]

I'm creating my first plugin and some widgets for a colleague's site, and I thought I'd separate the data retrieval part from the data display part, but I seem to be missing something (if it's even possible).

I've created a plugin that will query the database and return an array ($report_data) when certain conditions are met in the page url. I've got that working - print_r($report_data) confirms that the correct data is returned on the correct pages. (I've got the 'add_action' for the plugin set to "loop_start" ).

Now I'd like to have my widgets use that data to generate content for display - tables, graphics, etc... but when I load the widget into the post, I get an error that its missing the argument required (i.e., the $report_data array isn't being picked up by the widget).

Is what I'm trying to do even possible?
If so, what might I be missing?

Thanks,
Scott

cornelinux on "hook function for plugin options saved"

$
0
0

I was trying and googling for a while, but maybe I did not use the right keywords.

I am writing a plugin. I have a settings for that saves just fine.

I'd like to add a hook, to be able to either do some php stuff either before or after all my options are saved.

I thought I could find some code like

add_action("options_saved", "my_function");

I found several posts, but they seem do not seem to cover my concern.

Moreover: Would it be possible to pass data to such a hooked function, that will not be saved? I want to test the configuration on the server side and like to pass some user entered test data, that must not be saved.

THanks a lot and kind regards
Cornelius

Southwest on "Why does my visual post editor break when I try to add a TinyMCE button?"

$
0
0

I'm trying to add a button to my TinyMCE editor. I'm using WordPress 3.9.1 with a child theme, so I'm following this tutorial to add a new TinyMCE button. Right now, I'm just trying to get the tutorial version working--once that's done, I'll edit the button's script to actually do what I want.

I've added this to my child theme's functions.php file:

// Hooks your functions into the correct filters
function my_add_mce_button() {
// check user permissions
if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
return;
}
// check if WYSIWYG is enabled
if ( 'true' == get_user_option( 'rich_editing' ) ) {
add_filter( 'mce_external_plugins', 'my_add_tinymce_plugin' );
add_filter( 'mce_buttons', 'my_register_mce_button' );
}
}
add_action('admin_head', 'my_add_mce_button');

// Declare script for new button
function my_add_tinymce_plugin( $plugin_array ) {
$plugin_array['my_mce_button'] = get_template_directory_uri() .'/js/mce-button.js';
return $plugin_array;
}

// Register new button in the editor
function my_register_mce_button( $buttons ) {
array_push( $buttons, 'my_mce_button' );
return $buttons;
}

I've also created a script with the content below, and saved it as "mce-button.js" in the /js directory of my child theme's folder.

(function() {
tinymce.PluginManager.add('my_mce_button', function( editor, url ) {
editor.addButton('my_mce_button', {
text: 'New Button',
icon: false,
onclick: function() {
editor.insertContent('WPExplorer.com is awesome!');
}
});
});
})();

However, when I save all that and load the post editor (in the "Visual" tab), none of the buttons load, and I can't enter text in the editor. In fact, if I go to the "Text" tab and enter text, then switch back to the "Visual" tab, the text I entered doesn't appear.

You can see an image of my broken WordPress editor here.

Could someone please help me figure out why my TinyMCE editor is breaking, and how I can add buttons properly without breaking it?

Thank you!

easyp on "function override"

$
0
0

I'd like to override a function in woocommerce, specifically -
woocommerce/includes/wc-cart-functions.php (the wc_cart_totals_order_total_html function).

I could edit the function directly (it outputs html that needs to be changed), but I'd prefer not to as I'll lose changes on updates.

I'm sure it's a common thing, I'm just not quite sure how to go about doing that. If I copy the function to functions.php in my theme, I get an error about re-declaring the function.

thanks.

Viewing all 8245 articles
Browse latest View live




Latest Images