toocoolone
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: My Website no longer loadingTechnically, this doesn’t appear to be a WordPress issue. But it is definitely a problem if your website is missing!
What you are seeing is the index.php file of your WordPress install and it’s contained in your root directory. It appears your server is not interpreting the index.php file as PHP (which would end up displaying your website properly). Instead it’s outputting the PHP file in plain text.
It appears to be an issue with the server configuration. It’s possible you’ve been hacked, but it could be a software change or update by the host as well. Seems like they should make sure they didn’t cause the error before they charge you a hundred bucks!
My guess is your database is likely fine and the website is still there…the server is somehow misconfigured. There shouldn’t be a need to pay for a whole new website, IMHO. I’m guessing contacting the original developer to see if they can look into it is not possible?
Forum: Plugins
In reply to: [Recent Posts Widget Extended] Category Shortcode is not an ArrayIn your example you only indicated one. The original modification I suggested at the start allows you to pass a list of IDs in to the plugin.
[rpwe cat="4,6,3,7,9"]When you make the first modification I gave above (that breaks a list down into an array), list the categories you want excluded in
cat=""and add thecategory__not_inline it will hide any post with at least one of the categories on the list. It tested working when I tried it.The second question you asked: yes, these changes are for the widget. The shortcode relies on the core code you’re changing here so the behavior will be the opposite of what it normally is.
- This reply was modified 8 years, 1 month ago by toocoolone.
- This reply was modified 8 years, 1 month ago by toocoolone.
Forum: Plugins
In reply to: [Recent Posts Widget Extended] Category Shortcode is not an Array@ak71, maybe I wasn’t clear on one detail: This change does this as long as you update the shortcode to equal the category you want hidden. By changing
category__intocategory__not_inthe query ignores any posts that are in the category provided in the shortcode (the category ID you want to hide). This will only show the second post in the example above. The behavior is the inverse of what the plugin does normally.Forum: Fixing WordPress
In reply to: I can’t change subpage URLs?Under Settings >> General, make sure the WordPress Address and Site Address are set to your domain name. I just tested the site and it was working for me, so your browser’s cache may be playing tricks on you. Try surfing the page in safe-mode and see if the problem persists.
Forum: Fixing WordPress
In reply to: CSS problem@endgame421
It looks like the CSS selector.col.firstis causing the break. This is defined to have aclear:bothproperty on line 1 ofstyle.min.css. This is causing the gap on the mobile view. Consider allowing the columns to wrap as needed on the wider views. As you have it you’re forcing three columns, which is great until the screen gets too narrow for three columns. It is still trying to show three columns, which is causing the gap you’re seeing.Forum: Plugins
In reply to: [Recent Posts Widget Extended] Category Shortcode is not an Array@ak71
The easiest way to exclude the category IDs listed in the “cat” shortcode would be to change line 257 to read:$query['category__not_in'] = $args['cat'];Notice that we’ve changed
category__intocategory__not_inThis change causes the query to ignore instead of include the category IDs you have listed.Be careful when applying updates to this plugin as if the author updates the plugin it will wipe out these changes!
Forum: Fixing WordPress
In reply to: is_home works….is_front_page doesn'tCheck your setting in the admin menu: Settings->Reading->Front page displays. Are you displaying a static page or your latest posts? Depending on this setting decides how these two functions act.
is_home()is a function that returns true when the “blog posts index page” is loaded. It works on blog pages only. (Codex)is_front_page()is a function that returns true depending on the setting in your Settings->Reading->Front page displays. If you are set to “Your latest posts” it returns true just likeis_home()when you are on the page showing your latest posts. If the option is set to “A static page” and your static home page is showing, the function will return true only on that page. (Codex)Forum: Hacks
In reply to: Search results : only one result shows upOkay, I think I understand better what you’re trying to do. You should be able to control the pagination like this. Just make sure you’re passing the search string with the new query. What you’re doing is replacing the default query which is searching correctly with a totally new one, which only shows two random pages because the search string isn’t being passed to it.
Check out the WP_Query codex for more options. You can pass as many as you want by separating them with a
&.Remove the line:
$my_query = new WP_Query( 'posts_per_page=2' );And replace it with this:
$my_query = new WP_Query( 'posts_per_page=2&s=' . $_GET['s'] );Forum: Hacks
In reply to: Search results : only one result shows upMake sure when you are calling your while statement you are referring to your query. Instead of $the_query->have_posts() use $my_query->have_posts().
Also, place the new WP_Query call above everything else!
<?php $my_query = new WP_Query( 'posts_per_page=2' ); if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post(); ?> <div style="text-align: center"> <div class="boxxy"> <?php if ( has_post_thumbnail() ){ ?> <?php $thumbID = get_post_thumbnail_id($post->ID); ?> <a href="<?php echo get_post_meta($post->ID, 'URL', true); ?>" title="<?php the_title(); ?>" target="_blank"> <?php the_post_thumbnail(); ?> <span class="view-large"></span> </a> <?php } ?> <?php the_content('<p>Continue Reading →</p>'); ?><br /><br /> <?php if(function_exists('the_ratings')) { the_ratings(); } ?><br /><br /><br /> <?php edit_post_link('Edit this post'); ?> </div> </div> <?php endwhile; else : ?> <div id="sort"> <div class="box"> <h2>Sorry, no posts were found</h2> <?php get_search_form(); ?> </div> </div><!-- #sort --> <?php endif; wp_reset_postdata(); ?>Forum: Hacks
In reply to: Create custom pageYou could use a shortcode to do this. I’ve done something similar myself. The URL might have to be a little longer than what you want, but make a page with nothing but the shortcode in it. Then create a function to handle the shortcode that returns whatever data you wish. You can read in the Codex about shortcodes.
Forum: Hacks
In reply to: Modify the media uploaderThis worked for me. I got this from here. They have more info on other fields you might want to remove or add.
add_filter('attachment_fields_to_edit', 'remove_media_upload_fields', 10000, 2); function remove_media_upload_fields( $form_fields, $post ) { // remove unnecessary fields unset( $form_fields['image_alt'] ); unset( $form_fields['post_excerpt'] ); return $form_fields; }Forum: Hacks
In reply to: how to add line breaks for post custom fieldsIf your field is stored with new lines between each item in the list you could just do this…
<p class="shipping_address"> <?php { echo nl2br( get_post_meta($transaction_childdeal->post_id,'conditions',true) ); } ?></p>I’m not sure how the items are stored so that may not work!
Forum: Hacks
In reply to: Including a PHP file via a function that is part of a plugin?Have you tried dropping the ‘../’ when declaring an absolute path…that seems unnecessary and may be why the file isn’t being found?
function ContactInsert() { ob_start(); include(ABSPATH . "/contact.php"); return ob_get_clean(); }Forum: Hacks
In reply to: Dynamically Generating Content Without Using Publish FeaturesI’ve encountered this problem before while trying to get AJAX data out of WordPress and developed two ways of handling this. The key is to call your WordPress site in a valid way. There are two ways to do it and both require some knowledge of PHP. The first is to make a special “AJAX” template using a child theme and a special template.php file that does not provide the header and footer of your site. This way, the bare article from your DB is served up. It isn’t very dynamic, but it will get the job done in a pinch.
The other way is to use a plugin to “override” WP’s delivery of content while allowing things like DB access to remain. You serve your own content in a special way using a plugin. (Sounds like what you’re trying to do.) There’s a basic plugin that does this. It’s not a plugin in the truest form of the word — you have to edit the PHP files to get the content you want. It does allow you to override WP and deliver customized content without a header and footer. The method it uses to do this is what you’re interested in because it overrides WP’s default content engine and outputs its own stuff. You can read about it here and download an archive here.
The key part I think you’re interested in, however, is this:
$uri = null; $qry = array(); if( strpos( $_SERVER['REQUEST_URI'], '?' ) !== false ) { list($uri, $qry) = explode( '?', $_SERVER['REQUEST_URI'] ); $qry = $_GET; } else { $uri = $_SERVER['REQUEST_URI']; } $uri = rtrim( $uri, '/' ); $uri = ltrim( $uri, '/' ); $tokens = explode( '/', $uri ); if( array_shift( $tokens ) == $this->sniff ) { $this->controller = ucwords( strtolower( array_shift( $tokens ) ) ); $this->action = ucwords( strtolower( array_shift( $tokens ) ) ); foreach( $tokens as $token ) { $this->tokens[] = $token; } if( is_array( $qry ) ) { foreach( $qry as $key => $val ) { $this->tokens[$key] = $val; } } if( $this->controller == '' ) { $this->controller = $this->default_controller; } $this->template = DWP_PLUGIN_DIR . '/template.php'; } add_action( 'ajaxifier_do_framework', array( &$this, 'get_view' ) ); add_filter( 'template_include', array( &$this, 'get_template' ) );This is the __construct() method of a larger object. But what’s happening here is $this->sniff = ‘ajax’ for instance. Then when a user visits
http://yoursite.com/ajax/index/viewthis code will call another abstract object View::IndexView() and pass any arguments along to it.It uses a custom method to query the database and deliver the content, when called, or allows WordPress to continue unabated if not. The “template_include” hook allows us to use a custom template to deliver the content without a header and footer.
I think the concept of what you are trying to do is in this. You can serve content that you create yourself, from a different database or by any method you choose this way while still allowing WordPress to handle user authentication and database access. You could download the whole package and have a look at it. It may help you in your plugin development.
Forum: Hacks
In reply to: How To Select Category Also in SQL QueryIf you know the category ID (
$cat_id), you could use the following SQL, which has one additional AND clause which only allows ID’s that are associated with a given category matching$cat_idto be passed through.SELECT DISTINCT LEFT( post_title, 1 ) AS first_letter FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND ID IN ( SELECT object_id FROM $wpdb->term_relationships WHERE term_taxonomy_id = $cat_id ) ORDER BY first_letter ASCIt’s also good form to use
$wpdb->prepare()when sending queries to your database to prevent injection attacks even when dealing with variables that you’ve programmed because programmers make mistakes and a misplaced apostrophe could damage your database terribly. You can use the following to do that:$letters = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT LEFT( post_title, 1 ) AS first_letter FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' AND ID IN ( SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id = %d ) ORDER BY first_letter ASC", $cat_id ) );