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

Tatiane Pires on "How to check if a plugin is causing "Fatal error: Out of memory" issues?"

$
0
0

I wrote two plugins ("mu-plugins" to be more accurate) to create widgets: one display posts of the selected category, the other lists the recent posts. The widgets have several options like display excerpt, display image and so on.

But these plugins might be causing "Out of Memory" issues.

The plugins are very similar, and their codes are on the following pasebin links:
widget-list-posts-of-category.php
widget-list-recent-posts.php

I need some help on this. How do I check for memory related issues?


Bankitalia on "List of all posts below single post"

$
0
0

Hello,

I'm trying to do something which sounds so simple however I can't find anywhere a tutorial or similar that shows how to achieve it, and my PHP skills are very very basic, so those don't help much either.

Here's what I'm after: I'm in single.php and I'd simply like to display a list of all available posts (no restrictions at all as to category, date, author, etc.) in the page footer. Of course the list needs to be paginated. And that's the problem, 'cause with the code I have so far right now, pagination just won't show up.

Here's the code:

<?php

			$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

			$args = array(
				'paged' => $paged,
				'post__not_in' => get_option('sticky_posts'),
				'posts_per_page' => 9
			);

			$posts = new WP_Query( $args );

			if ( $posts->have_posts() ) :
			?>
				<?php while ( $posts->have_posts() ) : $posts->the_post() ?>
				<?php get_template_part('content', 'wall'); ?>
				<?php endwhile ?>
				<?php twentythirteen_paging_nav(); ?>
			<?php else : ?>
				<h2>Ooops, no posts here!</h2>
			<?php endif ?>

Any help would be MUCH appreciated!!

suge1w on "get_the_category query"

$
0
0

Hello,

I have this query:

foreach (get_the_category() as $cat)

How do I get the categories to order by ID and DESC rather than name?

devrrwatkins on "Removing an inserted link by external party"

CraigScales on "Make Theme Show Full Post instead of Excerpts"

$
0
0

Hi!

The Syntac theme I'm using won't allow a full post to show on the "blogs" page. My site is dev.craigscales.com.

Any ideas? My theme seems to be built differently than what most of the forums are saying should be the solution...

Thanks!

giwrgos88 on "wp_localize_script was called incorrectly"

$
0
0

Hi,
when I'm enabling the debugging for the website I'm getting the following message

PHP Notice:  wp_localize_script was called <strong>incorrectly</strong>. Scripts and styles should not be registered or enqueued until the <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, or <code>login_enqueue_scripts</code> hooks. Please see <a href="http://codex.wordpress.org/Debugging_in_WordPress">Debugging in WordPress</a> for more information. (This message was added in version 3.3.) in /www/*****/wp-includes/functions.php on line 3049

The reason is because one function that I did for my plugin, where I'm using the admin-ajax.php for ajax request

Here is the sort of the data that I have inside my index file of the plugin

Action which I'm using it to collect data from database using AJAX GET

add_action("wp_ajax_collect_admin_row_data", "collect_admin_row_data");
include (ABSPATH ."wp-content/plugins/my_plugin/include/actions/admin_collect_row_data.php");

Next I have the following function

$jquery_pages =array("user_area");

if ($GLOBALS['pagenow'] == "admin.php")
{
    $page = $_GET["page"];

    if (in_array($page, $jquery_pages))
    {
        add_action('admin_enqueue_scripts', "ajaxpaging_location");
    }
    else if ($page == "il_menu")
    {
        add_action('admin_enqueue_scripts', "menu_options");
    }
}

function ajaxpaging_location() {

    if (DEV_MODE)
    {
        wp_enqueue_script('ajaxscript', AJAXACTIONS.'js/jquery.actions.js', array('admin_custom_jquery_script'));

    }
    else
    {
        wp_enqueue_script('ajaxscript', AJAXACTIONS.'js/jquery.actions.min.js', array('admin_custom_jquery_script'));
    }
    wp_localize_script( 'ajaxscript', 'ajaxpagingscript', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) );

}

Inside jquery.actions.js I have the following code

function callGetAjaxRequest(parameters, sync_value)
{
    var result="";

    jQuery.ajax({
        cache: true,
        type: 'GET',
        accepts : 'json',
        async: sync_value,
        url: ajaxpagingscript.ajaxurl,
        data : parameters,
        success: function(data) {
            result = data.message;
        },
        error : function (data)
        {
            result = data.responseJSON;
            errorMessageController(data.responseJSON.message);
        }
    });
    return result;
}

The code is working fine but it throws the notice.
What actually I'm doing wrong and I get this notice?

monicaconey on "Can't access plugins or updates"

$
0
0

I cannot access the plugins or updates tab. It responds with a page not found. I am getting people sign up/register nonstop so somehow someone has this blocked so I cannot remove the plugin to register?? My site is ChiefExecutiveConnections.com. I do not do much to direct people to this site as most our business is by referrals so there is no reason all these yahoo email addresses are signing up. Help please.

worldtravelgeek on "Insert widgetized area into loop, independent of theme"

$
0
0

Hi guys,

I thought this would be simple somehow but I guess it isn't. Let me start by saying that I am no coder but willing to learn a bit if necessary. I was looking for a way to inject one (or more) widgetized area(s) into the wordpress loop, for instance before the 1st or 3rd etc post.

Now I have found a few instructions for that but mostly it consists of registering a dynamic sidebar in functions.php and then hack index.php or category.php etc by looking for "endwhile" and inserting the dynamic sidebar before that.

However, this is very theme dependent. Whenever I switch themes I need to adapt and reinsert that code to fit with the new theme, some of them don't even seem to have that "endwhile" in index.php.

So I was thinking of implementing this as a plugin, independently of the theme used. I have found a way to register the dynamic sidebar by creating a plugin consisting of a site_functions.php and adding this:

register_sidebar(array('name'=> 'WidgetArea1',
    'id' => 'Widget1',
    'description' => esc_html__('Widgets appear before 1st post', ''),
    'before_widget' => '<section id="%1$s" class="WidgetArea1">',
    'after_widget' => '</section>',
    'before_title' => '',
    'after_title' => ''
));

So now I know I am supposed to add something like this to the loop:

<?php
if ($count==1) {
dynamic_sidebar(‘WidgetArea1’);
}
$count = $count + 1;
?>

How and where can I do this (or something else ?) with my plugin so that the widget area appears in every theme, no matter how it displays the blog posts and which layout it uses (standard, masonry, isotope, etc) and without hacking theme files every time I switch themes.

Ideally that would also be extendable to archive or category pages etc

I am actually amazed that there doesn't seem to be a plugin on the market that can do things like that already. There are thousands of plugins available for wordpress but obviously not for something apparently simple like that. I hope it is possible ?!?

Thanks a lot for your help guys!
Alex

PS: If this is really complicated and any of you talented developers out there would prefer to create a plugin that does things like that I would even pay a little. Probably others as well ... ;)


jks0qqgg on "Phising Attack appears to be from WordPress"

$
0
0

I have been getting emails like this

"Howdy! Your site at http://192.185.87.173/~videouniversity has been
updated automatically to WordPress 4.1.3."
etc.

It invites me to login in my WordPress admin page. I believe someone is trying to steal my password.

I am not connected with that IP address, but I do own Videouniversity.com

The email is sent from echo.websitewelcome.com
That is a surrogate of hostgator.com, but complaining to them has been a waste of time.

I get the same email every couple weeks. Looking closer, it appears that they have stolen my entire site. Is there anything I can do about this?

Thanks

Joschua Boehm on "Pulling WP Data from many sites to one data warehouse"

$
0
0

Hi All,
I do data warehousing and Business Intelligence as my profession.

I have started some WP stores and blogs etc in preference to dot net nuke. I still have quite a few DNN sites.

What I am interested in is this. I want to build a cloud service for data warehousing WP data from client sites. What this will allow our client to do is as follows:

1. Connect 1 or more wordpress sites to our service.

2. Extract, clean, integrate, and store all their wordpress from separate sites into one data warehouse. They will have their own database or share a database as options.

3. Add additional data to the data warehouse to be integrated to their wordpress data.

4. Sophisticated BI will be placed over the top so allow greater insight in to the performance of their business or businesses.

This will be particularly aimed at people who are selling products or services.

We already have very sophisticated BI data models that have been used in many companies all around the world. We are looking at bringing such models and such capabilities to "the masses" who use such things as woo commerce etc.

The only bit we really do not have a handle on is connecting to the wordpress databases and pulling the data out and transforming it to a tablular format that makes sense inside a data warehouse.

We have a C++ ETL engine and we have an ODBC class that connects to mysql. It does have the 32K chunk limit for ODBC for data which will not be a problem in most cases. Just very long posts.

But taking a look inside the mysql databases for wordpress the data is stored in posts that are interpreted by WP at the time of execution. The posts have post types and then the data must be interpreted by post type.

I was wondering if anyone has undertaken a project to move the wordpress data to another database and unpacking it by post type on the way.

Failing that I was wondering if anyone has any pointers or tips for us on the best way to approach getting data out of the WP mysql database and across to a mysql staging area including unpacking the variable data in the various post types along the way.

I am thinking I am not the first person to think it would be a good idea to extract all the data from WP and transform it so that it is queryable in a database.

Thank you in advance for any assistance you may be able to afford us.

Best Regards

Joschua

wpfan1000 on "wp_mail not working with to address"

$
0
0

I am getting the email address of the author of a post with

$postauthoremail = the_author_meta('user_email');

This does contain the correct email address.

If I feed that into wp_mail:

wp_mail($postauthoremail, $subject, $message);

This does not work.

If I hard code the email:

wp_mail('myemail@domain.com', $subject, $message);

This does work.

I have tried adding quotation marks to $postauthoremail, converting it to string, etc and does not help.

Any help is appreciated.

Alain Kassabian on "How can a URL delete a post?"

$
0
0

I'm trying to wrap my head around how simply loading a URL can delete or modify comments or posts, which I presume are stored in the database. I've seen this ability referred to in several places:

https://codex.wordpress.org/Function_Reference/get_delete_post_link

class-wp-comments-list-table.php: $trash_url = esc_url( $url . "&action=trashcomment&$del_nonce" );

The Wordpress codex page on Nonces states: "For an example of how an nonce is used, an admin screen might generate a URL like this that trashes post number 123. You can see that the URL contains a nonce at the end: "

If anyone has a quick answer and can spare me waiting for my own conclusion, I'd appreciate it.

zaydB on "Custom Pagination"

$
0
0

Hey Guys,
I currently have a site utilising custom pagination for custom posts. I have a set number of posts per page and although I am able to traverse one page ahead or behind I am unsure as to how I can traverse 2 pages ahead or behind. I'm using the function get_next_posts_page_link() to traverse to the next page. Is there anyway I can use this function to go 2 posts of pages ahead? something like get_nex_posts_page_link(3) to get to page three. I have tried using the paginate links function which automatically generates links but due to how the themes css file is designed I am unable to use this function.
Any help will be greatly appreciated. I can provide more detail on my code on request.
Thanks :)

dea_om on "wp_list_table bulk action not working"

$
0
0

Hi,
I'm trying to do a plugin which uses custom table and custom post type with custom taxonomies. To show the data from the custom table I'm extending the wp_list_table class. The data is shown correctly, but my trouble starts when I want to delete the record or do anything on that page. I'm trying to implement the bulk delete and also the mouse over delete but it's just not working. The mouse over delete "button" is not appearing at all and when I click the apply button for the bulk delete it just redirects me to a You do not have sufficient permissions to access this page. I don't know what I'm doing wrong. Any ideas?
The code for the delete:

function column_name( $item ) {

		$delete_nonce = wp_create_nonce( 'bsp_delete_student' );

		$title = '<strong>' . $item['students_name'] . '</strong>';

		$actions = [
			'delete'=>sprintf('<a href="?post_type=%s&page=%s&action=%s&student=%s">Delete</a>', $_REQUEST['post_type'], $_REQUEST['page'], 'delete', $item->students_id)
		];

		return $title . $this->row_actions( $actions );
	}

	function get_bulk_actions(){
		$actions=array(
		'delete'=>__( 'Delete' )
		);
		return $actions;

	}
public function process_bulk_action() {

		//Detect when a bulk action is being triggered...
		if ( 'delete' === $this->current_action() ) {

			// In our file that handles the request, verify the nonce.
			$nonce = esc_attr( $_REQUEST['_wpnonce'] );

			if ( ! wp_verify_nonce( $nonce, 'bsp_delete_student' ) ) {
				die( 'Go get a life script kiddies' );
			}
			else {
				self::delete_student( absint( $_GET['student'] ) );

				wp_redirect( esc_url( add_query_arg() ) );
				exit;
			}

		}

		// If the delete bulk action is triggered
		if ( ( isset( $_POST['action'] ) && $_POST['action'] == 'delete' )
		     || ( isset( $_POST['action2'] ) && $_POST['action2'] == 'delete' )
		) {

			$delete_ids = esc_sql( $_POST['delete'] );

			// loop over the array of record IDs and delete them
			foreach ( $delete_ids as $id ) {
				self::delete_student( $id );

			}

			wp_redirect( esc_url( add_query_arg() ) );
			exit;
		}
	}

	public static function bsp_delete_student($id){
		global $wpdb;
		$wpdb->delete(
			"{$wpdb->prefix}students",
			[ 'students_id' => $id ],
			[ '%d' ]
		);
	}

I've changed the code a couple of times for the delete function but I always get the same error message. Any help would be greatly appreciated.

nomis on "Hooking up Page and Category specific widget area"

$
0
0

Hi everyone,
I’m pretty new to WordPress, StudioPress and PHP so I hope someone can help me. My site has two blog pages. One is a standard blog, and the other is for tutorials. I’ve written the PHP below to add a widget area to the standard blog page, and also to its three category pages. I’ve added a custom menu to this area so that the viewer can switch between blog categories and also go back to the standard/all category page.

Here’s the thing - It works just fine. But the PHP just doesn’t look quite right to me. Shouldn’t there be an “else” statement at the end rather than an “elseif” ? When I add it, everything breaks. And do I really have to repeat all this code four times? Couldn’t I just group the page/category numbers in one block?

Any help cleaning up this very amateur code would be greatly appreciated.

//* rise - Register blog-submenu widget area
genesis_register_sidebar( array(
	'id'            => 'blog-submenu',
	'name'          => __( 'Blog Submenu', 'epik' ),
	'description'   => __( 'Place submenu for Blog Page here', 'epik' ),
) );
//* rise - Hook blog-sub-menu widget area after header
add_action( 'genesis_after_header', 'add_blog_submenu' );
function add_blog_submenu() {
	if ( is_page('59') )
		genesis_widget_area ('blog-submenu', array (
		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
		'after'  => '</div></div>',
		)
	);
	elseif ( is_category('11') )
	genesis_widget_area ('blog-submenu', array (
		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
		'after'  => '</div></div>',
		)
	);
	elseif ( is_category('12') )
	genesis_widget_area ('blog-submenu', array (
		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
		'after'  => '</div></div>',
		)
	);
	elseif ( is_category('13') )
	genesis_widget_area ('blog-submenu', array (
		'before' => '<div class="wrap"><div class="blog-submenu widget-area">',
		'after'  => '</div></div>',
		)
	);
}

lacorietowers on "Plug in to password protect pages"

$
0
0

hopefully someone here can help me. I am looking for another way to password protect pages other than using the built in wordpress option. when i use that option i get this error message "/wp-login.php?action=postpass" and I've tried everything to fix it , with no avail. So it there another plug in that does the same thing the wordpress password protected page option does??

SMRogers on "Custom Field = Featured Image URL"

$
0
0

I am currently using Social Deals Engine and Postie to add posts to my website. Postie works great but there are a couple of fields it can't handle because the custom field names contain brackets [] and it breaks the Postie shortcode. The field I need to populate is the main deal image. Is there a function (maybe in functions.php) I can use to tell the _wps_main_deal_image[src] to use the same image url as the featured image?

Jonas Spaller on "WP Plugin won't create tables in Database"

$
0
0

Hey,

i can't figure out why my code to create 2 tables in the Database isn't working.

Here's the code:

<?php

    /* create tables for jQuery Maximage */

    function jqmi_create_tables() {

        global $wpdb;
	$charset_collate = $wpdb->get_charset_collate();
	require_once( ABSPATH.'wp-admin/includes/upgrade.php' );

        $jqmi_image_paths = $wpdb->prefix.'jqmi_image_paths';
        $jqmi_options = $wpdb->prefix.'jqmi_options';

        // wp_jqmi_image_paths

        $jqmi_sql_one = "CREATE TABLE ".$jqmi_image_paths." (
            id int(11) NULL AUTO_INCREMENT,
            path text NOT NULL,
            UNIQUE KEY id (id)
        ) $charset_collate;";

        dbDelta( $jqmi_sql_one );

        // wp_jqmi_options

        $jqmi_sql_two = "CREATE TABLE ".$jqmi_options." (
            option text NOT NULL,
            value text NOT NULL,
            UNIQUE KEY option (id)
        ) $charset_collate;";

        dbDelta( $jqmi_sql_two );

    }

    register_activation_hook( __FILE__, 'jqmi_create_tables' );

    /* initial information for wp_jqmi_options */

    global $wpdb;
    $wpdb->insert(
        $wpdb->prefix.'jqmi_options',
        array(
            'effect' => 'fade'
        )
    );

?>

humburger2015 on "DropDown Box Selector: Hiding blank fields"

$
0
0

I have a dropdown selector for languages. It was creating using the custom fields in WordPress. There will be some fields that i need to leave blank but the blank fields still show up in the drop down selector. Is there a PHP "if" statement that someone can supply me that would hide blank fields in the drop down. For example, 'if' character count is less than 1 then hide field?

Here is the code I currently have:
<!-- Countries Select Box -->
<select id="country_selector">
<?php foreach ($footer["countries"] as $country) : ?>
<option value="<?= $country['english'];?>" data-int-url="<?= $country['url'];?>" data-int-img="<?= $country['img'];?>" data-int-cc="<?= $country['cc'];?>">
<?= $country['native'];?>
</option>
<?php endforeach; ?>
</select>

slane00 on "Changing permalink structure for a single category"

$
0
0

Hi all:

In order to preserve URLs from our current Drupal site, I need blog posts on my new WordPress site to be of the form /blog/2015/05/some-cool-blog-post.

That's fine, except that if I just add /blog into the permalink I think this will happen to all my posts, which I don't want. I want this to be added only for posts in the Blog category.

Following some links on the Codes, it looks like I can hook into the permalink generation code and add the "blog" element when needed. But my efforts to do something even quite simple don't work.

I'm running this code in the functios.php file of my child theme:

function append_query_string( $url, $post, $leavename ) {
//if ( $post->post_type == 'post' ) {
$url = add_query_arg( 'foo', 'bar', $url );
//}
return $url;
}

add_filter( 'post_link', 'append_query_string', 100, 3 );
add_filter( 'post_type_link', 'append_query_string', 100, 3 );

I'd expect this to add the meaningless query var foo=bar to all my post URLs. But this isn't happening.

Do I need to reset, flush or restart something? Am I hooking into the wrong filter(s)?

Any thoughts appreciated.

Thanks,

Steve Lane

Viewing all 8245 articles
Browse latest View live




Latest Images