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

ranbos on "Change custom taxonomy term permanent url"

$
0
0

Hi,

I created a custom taxonomy called Games
Under it I have a term to list all the games on the website called Games
Also I have a term for each game
Games taxonomy, GTA term and so on.
In my child theme I use taxonomy.php to know which game to view, or shall I view a list of games.
I want to view the list of games like this
site.com/games/ and not site.com/games/games
So I did this working rewrite rule
$new_rules = "games/?$" => "index.php?games=games";
The problem is the game term's page is still recognized as site.com/games/games/ by other plugins like polylang for example.
I want to force word press to accept site.com/games/ only to reach the term games in taxonomy games.

Any help is greatly appreciated.


Leon Freeman on "How to Connect Multiple Databases for Search Results"

$
0
0

I having a trouble to connect multiple databases to pull search results, could you please help me to connect multiple databases for wordpress search, i'm testing this on local server.

- My databases names are: connect1, connect2, connect3, and every db has different username and password.
- I'm trying to pull all the posts and pages data from each db, so my posts goes into "wp_posts" and pages "wp_pages".
- And can i have custom "table_prefix" in wp-config file like instead of 'wp_' something like 'xyz_123" for each database?
- wordpress theme is 2016, (i guess you might need to know that).

Please also describe which code goes where like in what file etc.
many thanks!

Ian Schoonover on "Woocommerce Bookings Extension Resources Quantities"

$
0
0

Not sure if this is the place to put this, but..

Issue: I'm going to try to hack together a UI that displays the quantity of each resource created with the woocommerce bookings extension.

I don't know a lot of php, but I know JS and ruby so I'm fairly confident that I can throw something together with my limited knowledge of php.

I'm hoping there's a pre-made function that will return the quantity of one or all resources from the booking extensions plugin, and if there isn't then maybe I can write one.

The next step would be to make an interface that allows editing & updating of the quantities.

Any advice is welcome, or if anyone is confident that they can write the code for this feature, I'm happy to hire someone on a contract basis to do this and other php jobs on some wordpress websites I manage.

Thanks in advance.

bernardomeyer on "query_post category_name"

$
0
0

Prezados,

O query_post para nome da categoria deve ser usado utilizando-se como parâmetro o SLUG name.

Exemplo:

Minha categoria era Principal, mas o slug era "main".

no query_post usei:

query_posts('category_name=main');

Quando estava usando "Principal", é claro que dava errado.

ArtissTheGeek on "Translation of special characters from shortcode parameter"

$
0
0

One of my plugins allows a YouTube video ID to be passed as a parameter. However, some of the characters that makes this ID up can be translated to special characters. For example, two hyphens get translated to –

Is there a quick and easy way to translate these back? I assumed htmlspecialchars_decode would do it and, to an extent, it does. However, three hypehns gets translated to — but using htmlspecialchars_decode is gets converted back to two hyphens. Any thoughts on the best way to do it correctly?

David.

MalteseSolutions on "Help with a class"

$
0
0

I am converting one of my plugins to Class instead of functions and I am encountering an error. PHP classes are fairly new to me so I am having some trouble.

I am getting the following error:
Fatal error: Using $this when not in object context in ... on line 207

Here is the method inside the class:

public function getLocations(){

		$Locations = $this->db->get_results("select location_id, location FROM {$this->my_locations_db}");

		return $Locations;

	}

Line 207 starts with $Locations

I am calling the method from inside the class using:

// get all the locations
		$myLocations = self::getLocations();

I am calling this same method through another method without a problem.
I am getting the results I am seeking, however when I call it from a different method I get the error.

Your help would be greatly appreciated.

Thanks

chelovek on "MYSQL cron explanation help"

$
0
0

Hello,
I am analyzing MYSQL side of Wordpress and found code below for scheduled post:
i:1459196504;a:1:{s:19:"publish_future_post";a:1:{s:32:"8olmjno1k05rb1som1frr6u854";a:2:{s:8:"schedule";b:0;s:4:"args";a:1:{i:0;i:27;}}}}
Trying to figure out what s:32:"8olmjno1k05rb1som1frr6u854" stands for and where it was gotten from or how created.

anoushkaz on "Nextgen plugin - how to change the font size in the Description field"

$
0
0

My website is http://www.homelessofnapa.com/ I'm trying to decrease the font size in my portrait gallery. It's the description field in the NextGen gallery plugin. Do I need to modify the CSS in order to do this, if so, how do I do that? sorry, newbie here. I appreciate your help!


parakeet on "Users sharing taxonomies?"

$
0
0

Hi,

I am interested in creating a taxonomy system for my users.
In fact, I think this should be the same taxonomy used for posts.

So, is it possible to have the same categories/tags usable by both Users and Posts?

pinkhare on "How can I get the parent menu-item object(not ID) in my nav walker class?"

$
0
0

I want to get the parent object(menu object but not ID, not post object) in my nav walker or walker edit class?

I need to get the parent menu item's object in my extended Walker class, because I will use the relationship to add some custom settings for each menu items on the walker edit page.

I can get the parent ID of a current item by $item->menu_item_parent, but I need no id but an object. And I also can get WP_Post object of the parent item by get_post( $item->menu_item_parent ); in walker class, but it only returns a normal WP_Post object which is not including any information about menu_item_parent (this is because that I need to get all the ancestors and the information of the current item).

The following returns ''(null):
wp_get_nav_menu_items($item->menu_item_parent, array('post_type' => 'nav_menu_item', 'output' => OBJECT));

print_r($item);

WP_Post Object
(
    [ID] => 7490
    [post_author] => 1
    [post_date] => 2015-07-19 18:48:11
    [post_date_gmt] => 2015-07-19 18:48:11
    [post_content] =>
    [post_title] => Single Forum
    [post_excerpt] =>
    [post_status] => publish
    [comment_status] => open
    [ping_status] => closed
    [post_password] =>
    [post_name] => single-forum
    [to_ping] =>
    [pinged] =>
    [post_modified] => 2016-02-27 16:31:08
    [post_modified_gmt] => 2016-02-27 16:31:08
    [post_content_filtered] =>
    [post_parent] => 0
    [guid] => http://xxxxxx.com/?p=7490
    [menu_order] => 53
    [post_type] => nav_menu_item
    [post_mime_type] =>
    [comment_count] => 0
    [filter] => raw
    [db_id] => 7490
    [menu_item_parent] => 7493
    [object_id] => 7490
    [object] => custom
    [type] => custom
    [type_label] => Custom Link
    [title] => Single Forum
    [url] =>
    [target] =>
    [attr_title] =>
    [description] =>
    [classes] => Array
        (
            [0] =>
        )

    [xfn] =>
)

=> This is the object structure that I want to get.

and

global $post;
print_r(get_post( $item->menu_item_parent ));

WP_Post Object
(
    [ID] => 7493
    [post_author] => 1
    [post_date] => 2015-07-19 18:58:08
    [post_date_gmt] => 2015-07-19 18:58:08
    [post_content] =>
    [post_title] => Forum
    [post_excerpt] =>
    [post_status] => publish
    [comment_status] => open
    [ping_status] => closed
    [post_password] =>
    [post_name] => forum
    [to_ping] =>
    [pinged] =>
    [post_modified] => 2016-02-27 16:31:08
    [post_modified_gmt] => 2016-02-27 16:31:08
    [post_content_filtered] =>
    [post_parent] => 0
    [guid] => http://xeepress.com/?p=7493
    [menu_order] => 51
    [post_type] => nav_menu_item
    [post_mime_type] =>
    [comment_count] => 0
    [filter] => raw
)

=> Following information as missing in here:

[db_id] => 7490
    [menu_item_parent] => 7493
    [object_id] => 7490
    [object] => custom
    [type] => custom
    [type_label] => Custom Link
    [title] => Single Forum
    [url] =>
    [target] =>
    [attr_title] =>
    [description] =>
    [classes] => Array
        (
            [0] =>
        )

    [xfn] =>

Ciao121 on "Execute code once a day on users"

$
0
0

This is not strictly related to WP, but I'm doing it in a Wordpress powered site and maybe in WP there is a better way to do it.

I want to perform a check on a user once a day (if he comes to the site). Let's think he has a permanent login so I think if I use the wp_login action hook it is not sure the action will fire because he's not performing a manual login each time.

I was thinking to perform the action and, at the end of the action, set a cookie with a 24 hours expire time. So on each page load WP will check if the specific cookie is set and, if not, fire the action. But this need a cookie check on each page view.

Is this the best way to do it and is it safe?
Thank you!

Meitar on "$network_wide argument on plugin activate hook in multisite always empty string?"

$
0
0

I'm seeing strange behavior contrary to the WordPress documentation as well as contradicting this WP StackExchange answer regarding the value of the $network_wide argument for plugin activation hooks. Specifically, no matter when/where I test the value of $network_wide, the value is always an empty string. Example code/test case:

<?php
/**
 * A test plugin for the network_wide argument.
 *
 * WordPress plugin header information:
 *
 * * Plugin Name: Test Plugin
 * * Plugin URI: http://example.com/
 * * Description: This plugin tests whether or not the network_wide argument is correctly passed.
 * * Version: 0.1
 * * Author: Meitar <meitarm+wordpress.org@gmail.com>
 * * Author URI: https://maymay.net/
 * * License: GPL-3
 * * License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
 */

function test_plugin_activate($network_wide) {
    var_dump($network_wide);
    exit();
}
register_activation_hook(__FILE__, 'test_plugin_activate');

When activated on a subdomain-based multisite install, this code produces an error:

Plugin could not be activated because it triggered a fatal error.

string(0) ""

My first instinct is to assume I have done something wrong. I am using a VVV multisite development environment and still get this error.

I have searched Core Trac but the only ticket that seems relevant (ticket:14170) seems to have been closed years ago.

Am I missing something obvious or is this a regression?

P.S. I asked this over on StackExchange, too.

bradklosterman on "add_user_page (profile sub menu) with meta fields input"

$
0
0

Create multiple user_page (sub-page for profile menu page on the administration screen) on the admin_menu of an author. The function of each each page displays a screen that has user meta input fields and save button. The data needs placed in a pdf ready for print. This is what I have. I need to place user meta fields in each page. Any suggestions would be greatly appreciated.

add_action('admin_menu', 'my_users_menu');

function my_users_menu() {
add_users_page(__('Education and Qualifications ','userinfo2'), __('Education and Qualifications','userinfo2'), 'read', 'userinfo2', 'userinfo2');
add_users_page('Voluntary Experience', 'Voluntary Experience', 'read', 'userinfo3', 'userinfo3');
}

function userinfo2() {
if ( !current_user_can( 'read' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrapfile">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}

function userinfo3() {
if ( !current_user_can( 'read' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
echo '<div class="wrapfile">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}

tienduydng on "Get popular custom post type post by views"

$
0
0

Hi everybody!.
I have a problem with try to get popular post by views.

//////update post view
function wp_set_post_views($postID) {
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        $count = 0;
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
    }else{
        $count++;
        update_post_meta($postID, $count_key, $count);
    }
}
//To keep the count accurate, lets get rid of prefetching
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
//show view
function wp_get_post_views($postID){
    $count_key = 'wpb_post_views_count';
    $count = get_post_meta($postID, $count_key, true);
    if($count==''){
        delete_post_meta($postID, $count_key);
        add_post_meta($postID, $count_key, '0');
        return "0 view";
    }
    return $count.' views';
}
//////////this is my code to get list by views:
$arg = array(
 "post_type" => "product",
 "posts_per_page" => 10,
 "meta_key" => "wpb_post_views_count",
 "orderby" => "meta_value_num",
 "order" => "DESC",
);
$query = new wp_query($arg);
if($query->have_posts()) :
 while($query->have_posts()) : $query->the_post();
  the_title();
  echo '('.wp_get_post_views(get_the_ID()).')';
 endwhile;
endif;
?>

But the result is not correct. The list is still sort by post ID.
where is my error. How can i fix it. Thanks!

adokas on "Random posts on homepage on daily basis"

$
0
0

Cheers all, I'd like to show random posts on a daily basis (which means people would be able to see same posts for a day) and I don't just want to use 'rand' because I want to show a mixture of new posts and random posts(you might think that that doesn't make any sense but I have more than 1000 posts). I have a mediocre programming skills so I don't know where to start exactly. I'd be grateful if you can help me and give me some tips. Thanks!


massa974 on "Connect to an external database"

$
0
0

Hi guys,

So here's the thing : I was recently hired as a Wordpress trainer for students who have never used it. I accepted the job because the training program felt entirely under my scope of skills.

But when I met the students, I learned that there's a mandatory part of the training that I have no idea how to deal with :

On a Wordpress based subdomain, they need to connect to an external database which is linked to a Joomla install, to gather and display data from this external database.

Again, this is way out of my scope of skills, so I'd definately like some insights from you guys. (detailed if possible)

Please forgive me if this sounds like I want you to make my job, but since my employer here seems to see my incapacity in this field in an infavourable light, some help would be awesome.

Thanks !

fbattarra on "WP-Pro-Quiz: Statistics CSV export plugin"

mordaru on "Bot for JCE able to upload malicious file to up-to-date WordPress site"

$
0
0

I have a WordPress site hosted on a CloudLinux server, and for some reason malicious scripts were uploaded to my .cagefs/tmp folder by a bot.

File timestamps and the following log timestamps match exactly, so I'm puzzled how a hack/exploit for Joomla (afaik) worked on a WP install?

70.35.202.197 - - [03/Mar/2016:03:02:50 -0500] "POST /index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=cf6dd3cf1923c950586d0dd595c8e20b HTTP/1.1" 200 0 "-" "BOT/0.1 (BOT for JCE)"

70.35.202.197 - - [03/Mar/2016:03:02:58 -0500] "POST /index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=cf6dd3cf1923c950586d0dd595c8e20b HTTP/1.1" 200 0 "-" "BOT/0.1 (BOT for JCE)"

70.35.202.197 - - [03/Mar/2016:03:03:13 -0500] "POST /index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=cf6dd3cf1923c950586d0dd595c8e20b HTTP/1.1" 200 0 "-" "BOT/0.1 (BOT for JCE)"

70.35.202.197 - - [03/Mar/2016:03:03:21 -0500] "POST /index.php?option=com_jce&task=plugin&plugin=imgmanager&file=imgmanager&method=form&cid=20&6bc427c8a7981f4fe1f5ac65c1246b5f=cf6dd3cf1923c950586d0dd595c8e20b HTTP/1.1" 200 0 "-" "BOT/0.1 (BOT for JCE)"

pti150 on "Limit the size of images uploads in uploads folder only"

$
0
0

Hi, i wonder how to limit the size of the images uploads, because my editors keep uploading big images in their posts, keeping the possibility to upload bigger files in other folders (like the banner folderof adrotate for example).

northfool71 on "Drop down menu on touch screen"

$
0
0

Hi

I have a main menu on my WordPress site (KISBD.com) that has sub-menus. I've done a little research and it looks like a common issue on touch screen devices is how quickly the parent link will trigger before a child link can be chosen.

Is there a way to delay the parent link triggering longer to give the visitor more time to choose a child link in the sub-menu?

Or, is there a way to make the parent link inactive and have it only display the sub-menu when selected?

The latter would be preferable.

Many thanks

Viewing all 8245 articles
Browse latest View live




Latest Images