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

Jacob N. Breetvelt on "Console logging turned off"

0
0

I am a plugin developer and have a lot to troubleshoot. Always WP_DEBUG on etc.

The WP Admin pages seem to turn off the extremely usefull developers tool console.log(text); ( Firefox )

How can I prevent wp admin to switch off console logging?


frafor on "Auto term creation in a specific taxonomy according to a defined CPT post title"

0
0

Hi there,

I have two custom post types, say:

Labels
Artists

Artists has its own taxonomy, called again Label.

I would like to automatically create a term, within this taxonomy, for each post title present in the CPT Labels.

In this way, if i create a post titled "My Own Record" in Labels, then i'll get even "My Own Record" as a term within Artists's taxonomy "Label".

How can i get this? I've made some search, but i couldn't find anything similar.

Jpetracca on "Trouble with my loop: how to get next posts and previous posts working"

0
0

I'm having trouble getting the loop to show next and previous posts on a page.php.
The loop is supposed to show 10 posts (I set it down to 2 to try it out..) and then the next/previous posts link on the bottom... leading to the older posts if there are more than 10, etc...

site/page: tobylavigne.com/guidnace

<div class="col-md-8">
                     <?php
  $my_query = new WP_Query( array( 'numberposts' => 5,) );
  if( $my_query->have_posts() ):
     while( $my_query->have_posts() ):
        $my_query->the_post(); ?>

            <div id="fademobile" class="col-md-5" style="margin-top:30px"><div><?php if ( has_post_thumbnail()) : ?>
   <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
   <?php the_post_thumbnail( array(999999, 250)); ?>
   </a>
 <?php endif; ?></div></div>
            <div id="onlymobile" class="col-md-5" style="margin-top:30px"><div><?php if ( has_post_thumbnail()) : ?>
   <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
   <?php the_post_thumbnail( array(220, 9999999)); ?>
   </a>
 <?php endif; ?></div></div>
            <div class="col-md-7 block1 blogcontent">
            <div class="col-md-3 col-md-offset-2">
                    <div class="blogposttitle"><h3 class="text-center" style="margin-top:1px; color:#fff; font-size:1.3em; padding-top:2px"><?php the_time('F'); ?></h3><h4 class="text-center" style=" color:#fff; font-size:1em"><?php the_time('j, Y'); ?></h4>
                        </div>
                    </div>
                    <div><br><br><br>
                        <a href="<?php the_permalink(); ?>"><h4 class="text-center"><? the_title(); ?></h4></a>
                        <p><?php the_excerpt(); ?></p>

                    <div class="fb-share-button" data-href="<?php the_permalink(); ?>" data-type="button" style="top:-5px"></div>
                        <a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php echo get_permalink(); ?>" data-count="none" data-text="Check out <?php the_title(); ?>" data-via="TobyLaVigne" >Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
                        <script src="//platform.linkedin.com/in.js" type="text/javascript"  >
 lang: en_US
</script>
<script type="IN/Share" data-url="<?php the_permalink(); ?>"></script>

                    </div>

                </div>
                <?php endwhile; ?>
                <div class="navigation"><p><?php posts_nav_link(); ?></p></div>

                    <?php else : ?>
                    <h4>The Stuff You're Looking For Is Not Here!</h4>
                  <?php endif; ?>
</div>

Please Help - I'm up for anything that works!

7le on "404 display error - clashes with Permalinks"

0
0

I have seen a few posts about this issue but none of them have useful information about this issue which seems to happen in Fasthosts servers.

The real issue seems to be a server configuration problem, I have no real experience with Fasthosts but it seems that the way their servers are configured clashes with the way Wordpress handles pretty URLs and 404 error page gets cut off by a random number of characters and it's displayed as plain text (HTML source code).

An odd solution that I found was to add a HTML comment tag that wraps a random string, I used 7935 characters (including tag), for the issue to be solved, the number of characters my be different on other Wordpress sites and on different themes.

I'm posting this in case someone else get frustrated by this error and I'd like this to be helpful for others even if it's not really the best solution.

Cheers,
Raul.

Cold Iron Chef on "Adding an alternate header (PHP question)"

0
0

Hi,

I am editing the Tempera theme to have an alternate header on certain pages. I have succeeded thus far in finding the bit of PHP that lets me control that (in header.php), and wrote a bit of code to successfully insert my own code on select pages. I'm not very good at PHP (I'm still learning). This is what I've got so far, this works, except for the homepage.

<?php
if (is_page(array('38', '344', '498', '26', '48', '491')))
{
echo '<h1 class="customheadertitle">Services Sociaux</h1><h2 class="customheadertagline">pour personnes âgées 50 ans+</h2>';
}
?>
<?php
if (is_page(array('338', '54', '56')))
{
echo '<h1 class="customheadertitle">Programmes</h1><h2 class="customheadertagline">pour personnes âgées 50 ans+</h2>';
}
?>
<?php
if (is_page(array('352', '360', '367')))
{
cryout_branding_hook();
}
?>

What I would like my code to do is this:

If pages x,y,z etc... are being viewed, display Code A
If pages u,v,w etc... are being viewed, display Code B
If viewing any other page not listed above, then display default header ( cryout_branding_hook(); ).

I can't seem to get elseif statements to work for me, so I must be doing something wrong.

What is the proper code for doing what I want?

Thank you!

graemebryson5 on "Shortcode Query"

0
0

Hey,

I'm currently using a shortcode I found to display the username of the current logged in user. Using the currentuserinfo section in the codex, I've attempted multiple variations to have it display the 'firstname' instead. I'm a total novice with php - is this even possible with the current code I have (below)?

add_shortcode( 'current-username' , 'ss_get_current_username' );
function ss_get_current_username(){
    $user = wp_get_current_user();
    return $user->display_name;
}

Any advice would be massively appreciated!

marcelolz on "List Pages Sisters/Parents in Sidebar"

0
0

Hi!

How to add a list / menu in the sidebar to view the pages daughters and sisters of the current parent page?

The code below displays the correct list when it is inserted on the page, but the widget it lists all pages , not just of the current group . Is there a way to change it to also work on the side ? Or perhaps another solution ?

This page: http://www.cnbbsul4.org.br/projeto2014/para-familia/quando-ha-crise

Thank you !

hook :

<?php
$submenu = hierarchical_submenu($post);
if ($submenu) {
    echo $submenu;
} else {
    // Do something else
}
?>

In Functions page:

function hierarchical_submenu($post) {
    $top_post = $post;
    // If the post has ancestors, get its ultimate parent and make that the top post
    if ($post->post_parent && $post->ancestors) {
        $top_post = get_post(end($post->ancestors));
    }
    // Always start traversing from the top of the tree
    return hierarchical_submenu_get_children($top_post, $post);
}

function hierarchical_submenu_get_children($post, $current_page) {
    $menu = '';
    // Get all immediate children of this page
    $children = get_pages('child_of=' . $post->ID . '&parent=' . $post->ID . '&sort_column=menu_order&sort_order=ASC');
    if ($children) {
        $menu = "\n<ul>\n";
        foreach ($children as $child) {
            // If the child is the viewed page or one of its ancestors, highlight it
            if (in_array($child->ID, get_post_ancestors($current_page)) || ($child->ID == $current_page->ID)) {
                $menu .= '<li class="sel"><a href="' . get_permalink($child) . '" class="sel"><strong>' . $child->post_title . '</strong></a>';
            } else {
                $menu .= '<li><a href="' . get_permalink($child) . '">' . $child->post_title . '</a>';
            }
            // If the page has children and is the viewed page or one of its ancestors, get its children
            if (get_children($child->ID) && (in_array($child->ID, get_post_ancestors($current_page)) || ($child->ID == $current_page->ID))) {
                $menu .= hierarchical_submenu_get_children($child, $current_page);
            }
            $menu .= "</li>\n";
        }
        $menu .= "</ul>\n";
    }
    return $menu;
}

madsrh123 on "Get URL from the_field"

0
0

From this code: <?php echo the_field('transfile'); ?>

I get this out put:

3986, , Vis post, , , application/pdf, http://mask.de/jam/wp-content/uploads/2014/02/Vis-post.pdf

But what I really just want is the url. Can anyone tell me how I can isolate that?


kyle81192 on "How To Use This Web Tool?"

0
0

http://sourceforge.net/projects/piedb/

I am attempting to use this web tool with my word press.

I am relatively new to this.

I am unsure how to upload it as a plugin to word press.I have tried uploading as is and also re-zipping the decompressed folder.

How should I use this web tool?

Thank you

fsr678 on "Shortcode button on Tinymce front end?"

0
0

I am using a theme that has a front end submission form. Is it possible to include the shortcode button on the frontend tinymce editor?

It is working fine on the backend but would like to allow users to use shortcodes I create.

Thanks for a great plugin!

PS> Sorry for the double post. Didn't see the notice about hack forum until after posting.

Kleidi24 on "Send emails to some mail address if category id is = get_the_category($post_id)"

0
0

Hello to everyone.
I was looking around for a way to send automatic notifications to some mail address if a new post is published in some categories. I have found something around and modified a little bit but it's not working as i need it to. This is what i have at the moment:

function notify_new_post($post_id) {
    if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {

        $post = get_post($post_id);
		$postTitle=get_the_title($post_id);

		$postCategory=get_the_category($post_id);
		$postCategoryName = get_category($postCategory);

		$headers = 'From: My Website <my@website.com>' . "\r\n";
			if(($postCategory==11) || ($postCategory==59) || ($postCategory==15) || ($postCategory==22)  ){
				$sendTo = 'receiver@email.com';
				$email_subject = "[AL-ATA: ".$postCategory->cat_name."] ".$postTitle;
			}

			if(($postCategory==40) || ($postCategory==60) || ($postCategory==51) || ($postCategory==44)  ){
				$sendTo = 'receiver@email.com';
				$email_subject = "[EN-ATA: ".$postCategory->cat_name."] ".$postTitle;
			}

        ob_start(); ?>

					<?php echo $postTitle; ?> <br />

                    <?php echo get_the_content($post_id); ?>
        <?php

        $message = ob_get_contents();

        ob_end_clean();

        wp_mail( $sendTo, $email_subject, $message, $headers );
    }
}

add_action( 'publish_post', 'notify_new_post' );

It seems that is not sending in any emails.
If i remove the if statement and let it only check if new post is published and doesn't mater the category/categories id, it send the email.
I should say that a single post may have more than one category and i need to check all of those categories if one of them meats my needs.
Hope that someone can help me with this.

Thanks in advance!

lopo on "Problems with committing new version, anyone?"

0
0

I'm the developer of Duplicate Post plugin, yesterday I tagged a new version (2.5) and updated Stable Tag in trunk/readme.txt, but after a whole night the button still said "Download version 2.4.1" even if it was linked to duplicate-post.2.5.zip (not duplicate-post.zip...).
Morevover, in Developers section version 2.5 wasn't listed, and none of my sites got an update notice for my plugin.
That happened while 2.5/readme.txt was correctly displayed.

I thought that using Eclipse's tagging function could be the source of the problem, so I tagged version 2.6 "by hand" (creating the folder, adding it version control, copying there the files from trunk, committing) and then changing again Stable Tag in trunk/readme.txt: same result. Now version 2.5 is listed in Developers section, 2.6 isn't, and the button still says "Download version 2.4.1" while it's linked to duplicate-post.2.6.zip.
readme.txt from 2.6 is displayed.

It's been a couple of years since I last tagged a new version here, so I don't know if there have been any changes, but it doesn't seem so by re-reading the help pages in the Developer centre.
Is there anything going wrong with the Plugin Directory? Does any fellow plugin developer experienced a similar behaviour?

Pete on "Is it possible to automatically populate a custom taxonomy with a value"

0
0

Id it possible to automatically populate a custom taxonomy with a value based on another custom taxonomy's value?

How would one go about this?

Thanks, Pete

TIEro on "Register post status"

0
0

I've read through the Codex article explaining how to add a post status to WP, and have included the code in my plugin setup. I did it by hand at first, then used the generator:

function add_whatever_status() {
	$args = array(
		'label'                     => _x( 'whatever', 'Status General Name', 'text_domain' ),
		'label_count'               => _n_noop( 'Whatever (%s)',  'Whatever (%s)', 'text_domain' ),
		'public'                    => true,
		'show_in_admin_all_list'    => true,
		'show_in_admin_status_list' => true,
		'exclude_from_search'       => false,
	);
	register_post_status( 'whatever', $args );
}

add_action('init', 'add_whatever_status', 0);

The problem is that the status isn't appearing on any of the standard dropdowns.

The Codex gives the tip that "This function does NOT add the registered post status to the admin panel.[...] Consider the action hook post_submitbox_misc_actions for adding this parameter." What it doesn't do is provide any useful help - it links straight to the code for that hook.

Is there a simple function or hook or whatever that will get a custom status in the lists, please?

rerraw on "wordpress contact form don't work correctly"

0
0

hi i created modal contact form by twitter bootstrap and converted it by php to wordpress but when click on the send button i go to homepage
i don't why occure this error

my file
`<?php
// Function for email address validation
function isEmail($verify_email) {
return(preg_match("/^[-_.[:alnum:]]+@(((:alnum:|:alnum:[[:alnum:]-]*:alnum:)\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",
$verify_email)
);
}

$error_name = false;
$error_email = false;
$error_message = false;

if (isset($_POST['contact-submit'])) {
// Initialize variables for the form fields
$name = '';
$email = '';
$website = '';
$message = '';
$receiver_email = '';

// Get the name
if (trim($_POST['contact-author']) == '') {
$error_name = true;
} else {
$name = trim($_POST['contact-author']);
}

// Get the email
if (trim($_POST['contact-email']) == '' || !isEmail(trim($_POST['contact-email']))) {
$error_email = true;
} else {
$email = trim($_POST['contact-email']);
}

// Get the website
$website = trim($_POST['contact-url']);

// Get the message
if (trim($_POST['contact-message']) == '') {
$error_message = true;
} else {
$message = stripcslashes(trim($_POST['contact-message']));
}

// Check if we have errors
if (!$error_name && !$error_email && !$error_message) {
// Get the received email
$receiver_email = 'rerraw@gmail.com';

$subject = 'You have been contacted by' . $name;
$body = "You have been contacted by $name. Their Message is:". PHP_EOL . PHP_EOL;
$body .= $message . PHP_EOL . PHP_EOL;
$body .= "You can contact $name via email at $email.";

if ($website != '') {
$body .= "and visit their website at $website";
}
$body .= PHP_EOL . PHP_EOL;

$headers = "From $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Contetnt-type text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: qouted-printable" . PHP_EOL;

if (mail($receiver_email, $subject, $body, $headers)) {
$email_sent = true;
} else {
$email_sent_error = true;
}

}
}

?>

<?php if (isset($email_sent) && $email_sent = true) : ?>
<h3><?php _e('Success', 'Yallanpe-Theme'); ?></h3>
<p><?php _e('You have successfully sent the message.', 'Yallanpe-Theme'); ?></p>
<?php elseif (isset($email_sent_error) && $email_sent_error = true) : ?>
<h3><?php _e('Error!', 'Yallanpe-Theme'); ?></h3>
<p><?php _e('We coudnt send the message at this time please try again later.', 'Yallanpe-Theme'); ?></p>
<?php else : ?>

<div class="modal fade" id="contactus" tabindex="-1" role="dialog" aria-labelledby="modal-contactus" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="modal-contactus">Contact With Us</h4>
</div>
<div class="modal-body">
<form action="" method="POST" id="contact-form" role="form">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input value="<?php if (isset($_POST['contact-author'])) echo $_POST['contact-author']; ?>" type="text" class="form-control" name="contact_author" id="contact_author" placeholder="First Name" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input value="<?php if (isset($_POST['contact-email'])) echo $_POST['contact-eamil']; ?>" type="text" class="form-control" name="contact_email" id="contact_email" placeholder="Email Address" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
<input value="<?php if (isset($_POST['contact-url'])) echo $_POST['contact-url']; ?>" type="text" class="form-control" name="contact_url" id="contact_url" placeholder="Wbsite URL" />
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-comment"></span></span>
<textarea class="form-control" name="contact_message" id="contact_message" cols="60" rows="10" placeholder="Write Your Message Here"><?php if (isset($_POST['contact-message'])) echo $_POST['contact-message']; ?></textarea>
</div>
</div>
<div class="modal-footer">
<input type="hidden" name="contact-submit" id="contact-submit" value="true" />
<input type="submit" class="btn btn-default" data-dismiss="modal" value="Go Back" />
<input type="submit" class="btn btn-primary" value="Send" />
</div>
</form>
</div>
</div>
</div>
</div>

<?php endif; ?>


Pete on "Howe to Display defined Category (and all child cats) Assigned to a Post"

0
0

I'm using this piece of code but i'm trying to hack it so that it only displays a specified category (manually)... and all it's child categories(automatically).

<?php
$taxonomy = 'category';

// get the term IDs assigned to post.
$post_terms = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
// separator between links
$separator = ', ';

if ( !empty( $post_terms ) && !is_wp_error( $post_terms ) ) {

	$term_ids = implode( ',' , $post_terms );
	$terms = wp_list_categories( 'title_li=&style=none&echo=0&taxonomy=' . $taxonomy . '&include=' . $term_ids );
	$terms = rtrim( trim( str_replace( '<br />',  $separator, $terms ) ), $separator );

	// display post categories
	echo  $terms;
}

?>

marcomilic on "How to change url of all images in wordpress media library?"

0
0

Hello,

I am working on large website (to many images, posts, large database), and I need to change almost every url of image in wp-content/uploads/ to target a one specific image. I have tried with WP RegEx Replace plugin, using this instructions but it's not working. When I try to change specific url of one image it work, but if I want to select all images using wp-content/uploads/(.*)/(.*).jpg it's not working.

Do you have idea how to do this?

madsrh123 on "Post type inside another post type"

0
0

I need help "linking" one post type to another.

I've got one post type called 'album'. This contains the title of the album and the track titles entered into a text field with unique names (track1, track2, ...).

Then I've got another post type 'lyrics' with more information about each song (text, file attachments, creator information, ...).

Inside 'lyrics' I need to be able to select which track I want to add information about.

How can I do that?

TIEro on "Duplicating actions behind Submit button"

0
0

Is there a list somewhere of all the actions that pressing the "Submit for Review" button kicks off? Or a simple way to call the same set of functions?

I'd like to present a "Submit" option in a custom posts list, you see. I can do it with php/MySQL if I have to, but I figured it'd be more elegant if there's a WP function that does the same thing.

Tried searching the Codex, but...

Thanks!

bpence on "Turn Off Media File Renaming When Media File Edited (rotated, cropped, etc.)"

0
0

I'd like to edit media files via WP but need to keep the same filename. In other words, is there a way to turn off the automatic suffix generation that is attached to the end of the filename?(It's usually a series of numbers). I'd like it to overwrite the original file! Any help would be GREATLY appreciated!

Viewing all 8245 articles
Browse latest View live




Latest Images