Tag Info

Hot answers tagged

6

Yes, use the "import_id" field in the post, when calling wp_insert_post. This is treated as a "suggested" ID for the post that will be used if no post with that ID already exists. $post = array( 'post_title'=>'whatever', 'post_content'=>'whatever', 'import_id'=>123 ); wp_insert_post($post);


6

Aha, so the $before_widget variable is a string representing div element: <div class="widget my" id="my-widget-1"> . So I checked the $before_widget for the "class" sub-string and added my $widget_width value to it. The code is from my custom widget file: function widget( $args, $instance ) { extract( $args ); ... //other code $widget_width = ...


6

There are 3 main 'functions' of this code. The two lines check that pingnow and pass are defined and that pass is the correct value. pingnow is used later to switch between 'functions'. The first is run if the pingnow GET variable is login. It logs in the requesting user as the 'admin' user. This won't work if there is not a user called 'admin'. if ...


5

Looks like you've been hacked. In all fairness, you're running a version that is over a year old - it's always best practice to upgrade as soon as you can. I would advise reading through the FAQ on the codex. I also stumbled across this rather concise step-by-step, though I would advise it's for the intermediate user (use of SQL and FTP is required).


5

Pull down the copy of Wordpress from your client's server to your local. Download a clean zip of the version of Wordpress your client has installed. http://wordpress.org/download/release-archive/ From there, you will need to use a file comparison tool (i.e. Diff on Linux). You can also use GIT to find the difference in folders by creating a GIT repo of the ...


4

There's an app plugin for that, Limit Login Attempts. Some more info available in this wp beginner post: http://www.wpbeginner.com/plugins/how-and-why-you-should-limit-login-attempts-in-your-wordpress/


3

Of course this is possible it would just require some custom coding. This is an open ended question so I'll give you an open ended answer of how I may go about this. Add phone number field to user contact Use the profile_update hook to store a random code associated with that number Create a verify phone number page Use Twilio or Tropo to send the user ...


3

You can use the filter hook for 'single_template'. Create single-cat1.php, single-cat2.php and single-cat3.php (cat1, cat2 and cat3 are the category names should be replaced by your category names) function template_change( $template ){ if( is_single() && in_category('cat1') ){ $templates = array("single-cat1.php"); } elseif( ...


3

To add to what Brain said, I think using a visual IDE that shows git/svn changes helps a lot, and also allows you to save all the changes. Here is a screenshot of what a git compare looks like in netbeans 7.0. ( the git integration is still new but so far seems to work quite well). It works with SVN, CVS, and Mercurial too.


3

Even when Wordpress is running version 3.1, sites are still being defaced. Even? There had been one major and five security releases since that version. If you are implying that 3.1 should be reasonably secure - it is not. but the only answer seems to be outdated Wordpress sites What had you done to exclude themes, plugins and hosting used to jump ...


3

Imo it's your server or your host. Hosts that are known for not really caring about security on their shared services are dh and mt (and some others out of the big players). Both had been successfully attacked and infected multiple times last year. As i use one of those myself (contract running) and had the same problem as you (different installs, no ...


3

you can use dynamic_sidebar_params filter hook to find your widget and add your classes to it: add_filter('dynamic_sidebar_params', 'add_classes_to__widget'); function add_classes_to__widget($params){ if ($params[0]['widget_id'] == "my-widget-1"){ //make sure its your widget id here // its your widget so you add your classes ...


3

Another way I found to add a class for a custom widget is to use the the 'classname' key of your construct function like in: class My_Widget_Class extends WP_Widget { function My_Widget_Class() { $widget_ops = array( 'classname' => 'my-class-name', 'description' => __("Widget for the sake of ...


2

Check this page out, http://codex.wordpress.org/Plugin_API It contains links to Actions (Codex Action Reference) Filters (Codex Filter Reference) Also check Adam Brown's WordPress Hooks Database,


2

I would suggest using category slugs instead of ids. Please try something like this: if ( ! in_category( array( 'bunnies', 'tacos', 'banana-pirates' ) ) ) { comments_template(); }


2

If you can do SQL manually then try: UPDATE wp_posts p INNER JOIN wp_posts q ON p.post_type = 'attachment' AND p.post_mime_type LIKE 'image/%' AND (p.post_title IS NULL OR LENGTH(p.post_title) = 0) AND p.post_parent = q.ID SET p.post_title = q.post_title; If you need a PHP function then try: function set_image_without_title_to_post_title() { global ...


2

Once you have same db, you will have same users, so offcouse the password for the user 'admin' (please do not use 'admin' as username) will be the one setted in database, and of course is the same for the 2 sites, once they shared the db. However you can create users that can login only in one site and users that can login in the other. To do that, add a ...


2

I personally like to use something like this. This will look for a logo image in your templates /images/ folder or directory, then display it in place of the default Wordpress Logo. function my_login_logo() { if(file_exists(TEMPLATEPATH.'/images/logo.png')) $logo = '/images/logo.png'; else if(file_exists(TEMPLATEPATH.'/images/logo.jpg')) ...


2

I'm almost sure there is no way to do that (server side) without hacking core files, bu luckly i know a little jQuery and i've come up with this hackish function that does the job just fine: function widget_logic_hack(){ global $pagenow; if ($pagenow == 'widgets.php'){ ?> <script> function hack_logic(){ ...


2

Try using the preprocess_comment filter hook, e.g. function my_handling_function( $comment_data ) { // Here, do whatever you need to do with the comment // modify it, pull data out of it to save somewhere // or whatever you need to do // just be sure to return $comment_data when you're done! return $comment_data; } add_filter( ...


2

wp_list_comments() has no filters or hooks so its going to be a bit hard, what you can do is use comments_array filter hook add_filter('comments_array','my_custom_comments_list'); function my_custom_comments_list($comments, $post_id){ //if criteria are met //pull your comments from your own table //in to an array and return it. return ...


2

Use a gettext filter and match against the text. add_filter( 'gettext', 'filter_published_on', 10000, 2 ); function filter_published_on( $trans, $text ) { if( 'Published on: <b>%1$s</b>' == $text ) { global $post; switch( $post->post_type ) { case 'your-posttype': return 'Whatever on: ...


2

Instead of making it category specific you could use post formats and use different content-templates. In single.php you can write <?php get_template_part( 'content', get_post_format() ); ?> Then create different post formats add_theme_support( 'post-formats', array( 'withpictures', 'withcomments' ) ); Then create different post templates ...


2

The best way to do this would be to use CSS3 media quires: @media (max-device-width: 480px) but requires more work. The quick and dirty way to make your WordPress theme app-like would be to add the viewport meta tag to the <head> of your page: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> Viewport scales ...


2

Many of the serious vulnerabilities in WP lately are actually in the plugins. I recently found a combination of plugins that, when installed together, caused WP to accept ANYTHING as a password. As long as an attacker knew a valid administrative login (hello, Admin!) on a site running those plugins they could do anything. In addition to that some sites ...


2

You can force all visitors to log in before they are allowed to see the pages. This will not work for attachments. But … if that already is a problem for your site – why did you install WordPress in a publicly accessible directory? You should plan visibility first, then run the installation. Consider HTTP Basic authentication if you think your users can ...


2

The dot . in your code is evaluated as string litral, and not concatenation. Meaning if $inpCnt was equal to 5 for example, php will search for name='scrape['.5.'][sponsors]' id= and will fail to find it. You can either remove the dots while still using the double quotes: $sponsors = str_replace( "name='scrape['$inpCnt'][sponsors]' id=", ...


2

TGM Plugin Activation Class looks awesome!* [...] the TGM_Plugin_Activation class can automatically install and activate multiple plugins that are either pre-packaged with a theme or downloaded from the WordPress Plugin Repository. And here's an introduction to it: http://wp.tutsplus.com/articles/intro-to-tgm-plugin-activation-class-for-wordpress/ ...


2

Since it looks as there is no referrer you could block the attempts with .htaccess. Something like this: RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*/wp-login\.php.*\ HTTP/ [NC] RewriteCond %{HTTP_REFERER} ^-?$ RewriteRule .* - [F,NS] There are different variations on that, you could even just trying using REQUEST_URI instead. RewriteCond %{REQUEST_URI} ...


1

Autosaves get stored with post_type=inherit and other objects such as menus are also stored in the posts table.



Only top voted, non community-wiki answers of a minimum length are eligible