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

imlyrics on "WordPress Crowdfunding"

$
0
0

Hi everyone am looking to start a sponsorship base site in my community that enables individuals to post ideas and innovation in the frontend and giving abilities to certain users (sponsors ) to sponsor the idea. I know there are plugins to do that already but they are kinda expensive given that they don't really offer what I intend to have. I want my site to function somewhat like http://www.equitynet.com or http://www.crowdcube.com.
anyone has suggestion on how to go bout this?


Mike_Oberdick on "Post Thumbnail for Child Term"

$
0
0

I'm creating a gallery of images using a cpt "artwork". I also have a hierarchical taxonomy called album which is where I sort each image into a gallery. So I would upload an image as "artwork" and give it an album like Paintings->2015->Flowers. I will then add more artwork from other years so there will be several years under the top parent Paintings.

I'd like to have a page where I show all of those years (2015, 2014, etc.) with a thumbnail of an "artwork" post. I'd like that thumb to come from one of the child albums of that year. Currently I have it working but the thumb is the same for all of the years. I'm stuck and would appreciate any help!

Here is the live site and my code:

$term_children = get_terms ( //array of the terms
'album',
array(
'parent' => get_queried_object_id(), //get terms based on the parent
'order' => 'DESC', //order them descending so newest year is first
  )
    );

if ( ! is_wp_error( $terms ) ) {
    foreach ( $term_children as $child ) { //iterate over terms and return each as their own using $child variable

// grab one post from a child term
$thumbnail_post = get_posts( array(
        'posts_per_page'    => 1, // only one post
        'tax_query'         => array(
            array(
                'taxonomy'  => 'album', // from this taxonomy
                'parent'     => $child->term_id
        )
        )
        )
        );

echo '<a href="' . get_term_link( $child ) . '">
<div class = "taxonomy_thumbnails">';
echo get_the_post_thumbnail( $thumbnail_post[0], 'thumbnail' ); // show the random post's thumbnail
echo '<p>' . $child->name .' </p>';
echo '</div> <!-- .taxonomy_thumbnails -->';
echo '</a>';
    }

}

alexislevrai on "Sort tag archive by posttype"

$
0
0

Hi everyones,

I want to sort my tag archive (tag.php) in three section for my three post-type.
I actually have this :

$term_id = get_query_var('tag_id');
$taxonomy = 'post_tag';
$args ='include=' . $term_id;
$terms = get_terms( $taxonomy, $args );

$query = new WP_Query(
	array(
			'post_status' => 'publish',
			'post_type' => 'myCPT',
			'tag_slug__in' => $terms[0]->slug,
			'posts_per_page' => -1,
	) );
while ($query->have_posts()) : $query->the_post();

And I don't understand why is it not working ! My WP_Query is correctly define …
I actually see all post type from the current tag page.
Someone have an idea ?

Thanks for your help.

nikola797992 on "Pages disappeared in drop-down menu"

$
0
0

I have recent posts in my drop-down menu but the pages disappeared.
Drop-down menu or sub menu whatever you call it is in the top right corner.
Domain url is https://www.jumpmanual.org/

luarb on "Allow HTTP_USER_AGENT to collect data from users."

$
0
0

Hello , i am trying to code something to collect data
from my visitors about their browser and OS.

I found this function named HTTP_USER_AGENT and it worked till i tryed
inside my wordpress site.

Can anyone help me how to make this happen ?

Thank you.

DrMosko on "is htacces limit to ip enough for wordpress security"

$
0
0

hello,
is htacces limit access to wp-admin to my ip only enough for wordpress security, or should I use some wordpress plugin to secure the whole site, itried to use wordfence but since everybody know the url for login I get a lot of attacks.
thank u

hamdusa on "How to change search query string to permalink?"

$
0
0

I have redirected search page to new pretty URL, but that page now shows error 404. What extra code do I have to add to deal with URL on that error page.

Here is my code so far:

add_action( 'template_redirect', 'change_search_url_rewrite' );

function change_search_url_rewrite() {
    if( isset( $_GET['search_lat'] ) || isset( $_GET['search_lng'] ) || isset( $_GET['search_city'] ) )
    {
        $new_uri    = array( );

        if( isset( $_GET['search_lat'] ) && strlen( $_GET['search_lat'] ) )
        {
            $new_uri[]  = urlencode( 'lat-'.$_GET['search_lat'] );
        }

        if( isset( $_GET['search_lng'] ) && strlen( $_GET['search_lng'] ) )
        {
            $new_uri[]  = urlencode( 'lng-'.$_GET['search_lng'] );
        }

        if( isset( $_GET['sort'] ) && strlen( $_GET['sort'] ) )
        {
            $new_uri[]  = urlencode( 'sort-'.$_GET['sort'] );
        }

        if( isset( $_GET['search_city'] ) && strlen( $_GET['search_city'] ) )
        {
            $new_uri[]  = urlencode( 'city-'.$_GET['search_city'] );
        }

        if( isset( $_GET['search_category'] ) && strlen( $_GET['search_category'] ) )
        {
            $new_uri[]  = urlencode( 'category-'.$_GET['search_category'] );
        }

        if( isset( $_GET['search_type'] ) && strlen( $_GET['search_type'] ) )
        {
            $new_uri[]  = urlencode( 'type-'.$_GET['search_type'] );
        }

        if( isset( $_GET['search_neighborhood'] ) && strlen( $_GET['search_neighborhood'] ) )
        {
            $new_uri[]  = urlencode( 'neighborhood-'.$_GET['search_neighborhood'] );
        }

        wp_redirect( home_url( "/properties-search-results-2/" ) . implode( '/' , $new_uri ) );

        exit();
    }
}

add_action('init', 'custom_rewrite_rule', 10, 0);

function custom_rewrite_rule()
{
    add_rewrite_rule(   "properties-search-results-2/category-([^/]*)/city-([^/]*)/lat-([^/]*)/lng-([^/]*)/neighborhood-([^/]*)/sort-([^/]*)/type-([^/]*)/?" ,
                        '?page_id=16&search_lat=$matches[3]&search_lng=$matches[4]&sort=$matches[6]&search_city=$matches[2]&search_category=$matches[1]&search_type=$matches[7]&search_neighborhood=$matches[5]' ,
                        'top' );
}

**Another question is, how to check if re-writing is done and custom_rewrite_rule() is functioning successfully.

jesusangel.delpozo on "git svn dcommit fails with PHP Error"

$
0
0

Hello,

I have developed a free plugin for Wordpress. I use git as control version system and I commit changes to SVN repository with "git svn dcommit".

Some weeks ago I pulled two commits from a contributor. Firts commit had a syntax error, which was fixed in the second one. This is the log history:

b817937 Fixed redefined Services_JSON class error
6d97008 Replaced home_url with plugin_url to support sites with different plugin folder.
cc3dece Fixed apply_filters mistake
4ad0f87 Autodetect plugins folder
d01987d Fix compatibility issue with WooCommerce <= 2.1

Commit 4ad0f87 introduced a PHP syntax error, which was fixed in next commit (cc3dece).

SVN trunk is synchronized with git at d01987d commit. I can't publish changes to SVN cause the first uncommited commit has a syntax error.

Committing to http://plugins.svn.wordpress.org/woocommerce-sermepa-payment-gateway/trunk ...
        M       wc_redsys_payment_gateway.php

ERROR from SVN:
Un 'hook' del repositorio falló: Commit blocked by pre-commit hook (exit code 1) with output:
PHP Parse error:  syntax error, unexpected ',' in - on line 101

***********************************
PHP error in: woocommerce-sermepa-payment-gateway/trunk/wc_redsys_payment_gateway.php:
Errors parsing woocommerce-sermepa-payment-gateway/trunk/wc_redsys_payment_gateway.php
***********************************
W: b81793732ac30514b896ab2009efcdbe67caa1f3 and refs/remotes/trunk differ, using rebase:
:040000 040000 7ca06317d4a1104258981be8299d4059843f5939 b37c908255f37804a57c00c3a39351c0da33a7ce M      libs
:100644 100644 312ccc13e97e896187c229eeb8f10d2cb7676a47 2064e935d475a226caa1b36e0573d98b771970ef M      readme.txt
:100644 100644 c54918043016c3d7fad6213c004f4a633e2771df f76fe73c0ed651b70e5ac37fc8f742c607858f76 M      wc_redsys_payment_gateway.php
Current branch master is up to date.
ERROR: Not all changes have been committed into SVN, however the committed
ones (if any) seem to be successfully integrated into the working tree.
Please see the above messages for details.

How can I publish pending changes to SVN repository?

Kind regards,


tibetanitech on "Translate WordPress archive Year and count values"

$
0
0

Hello all,

I desperately need help in converting the WP archive values in our language i.e Tibetan. Since the website is build in only our language we are not using WPML. We have archive dropdown list in category.php and I could find the following code to replace the month values in archive which is working great, but i couldn't find a way to translate the year and count values. Please help.

In category.php
<select name="archive-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;">
<option value="">
<?php echo esc_attr( __( 'འཚོལ།' ) ); ?></option>
<?php wp_get_archives( array( 'type' => 'monthly', 'format' => 'option', 'show_post_count' => 1 ) );
?>
</select>

In functions.php
// Translate WP archive months

add_filter('get_archives_link', 'translate_archive_month');

function translate_archive_month($list) {
$patterns = array(

'/January/', '/February/', '/March/', '/April/', '/May/', '/June/',
'/July/', '/August/', '/September/', '/October/', '/November/', '/December/'
);

$replacements = array(
'ཟླ་དང་པོ།', 'ཟླ་གཉིས་པ།', 'ཟླ་གསུམ་པ།', 'ཟླ་བཞི་བ།', 'ཟླ་ལྔ་པ།', 'ཟླ་དྲུག་པ།',
'ཟླ་བདུན་པ།', 'ཟླ་བརྒྱད་པ།', 'ཟླ་དགུ་པ།', 'ཟླ་བཅུ་པ།', 'ཟླ་བཅུ་གཅིག', 'ཟླ་བཅུ་གཉིས།'
);

$list = preg_replace($patterns, $replacements, $list);
return $list;
}

Thank you!

zarga on "Change from "Link to None" to "Link to Media File" for already uploaded images"

$
0
0

Hello. I want to set all my uploaded images link to media file. Is there a way to do this automatically?

fistcloud on "rand"

$
0
0

Hi
I want to change the code of prporty archive to random

this is the code of archive

<?php

global $wp_query;

$default_sort = aviators_settings_get_value('properties', 'properties', 'default_sort');
if(isset($_GET['filter_sort_by'])) {
$default_sort = $_GET['filter_sort_by'];
}

echo View::render('archive-property.twig', array(
'wp_query' => aviators_properties_filter(TRUE),
'properties' => aviators_properties_filter(FALSE),
'default_sort' => $default_sort,
));

thnks

Archie22is on "Extend Custom Post Types"

$
0
0

Hi guys,

I purchased a theme from some provider. It came per-packaged with a few custom Custom Post Types.

My Questions: Without editing the plugins or exporting theme from the:
wp-content/themes/purchasedtheme/includes/some-cpt.php

  1. Is there a way to extend the Custom Post Types from the functions.php file?
  2. I basically want to add additional meta fields to the custom post types and also add dashicons. Can I do that in a functions.php away from the included Custom post types? It it good practice?.

I do not want to move theme from their current location for the sake of the theme. I might have to update the theme and if I die, perhaps the next person may not understand what I did.

If there

agnanzakariya on "How to hacks pretty URL link rel"

$
0
0

Generally, when I shot the source, basic thing when I see my CSS or JS link rel is like below:
'<link rel="stylesheet/less" type="text/css" href="http://blog.zakariyasoewardi.co.uk/wp-content/themes/wordpress-bootstrap/less/bootstrap.less">'

I use third party plugin who claim can make nobody know I use WP, I'm sure my link rel will be like below if I setting with that:
'<link rel="stylesheet/less" type="text/css" href="http://blog.zakariyasoewardi.co.uk/node/1/wordpress-bootstrap/less/bootstrap.less">'

But in specific case, I need hack URL link rel much easier when people or I shot the source, this is what I mean:
'<link rel="stylesheet/less" type="text/css" href="/wordpress-bootstrap/less/bootstrap.less">'

Is it possible?

stormbox on "[Plugin: Events Manager] Wordpress 4.4"

$
0
0

After upgrading to Wordpress 4.4 I received type mismatch errors on the Events page and the upcoming Events widget:

Warning: array_map(): Argument #2 should be an array in /home/content/46/8893746/html/heartstart/wp-includes/category-template.php on line 1158

This has been identified as a Wordpress bug and a patch has been released and presumably will be included in Wordpress 4.4.1. Until then I found the workaround described at this link worked for me:

https://wordpress.org/support/topic/getting-warning-array_map-argument-2-should-be-in-array

Hope this helps somebody with the same problem.

Regards,
David

https://wordpress.org/plugins/events-manager/

greguh on "Javascript not running in Wordpress"

$
0
0

Hi,

i'm trying to run Js code into wordpress, using a plugin; but can't make it work.

Here on this Codepen page, you can see the element i'm trying to integrate on my site (ie. a drag and drop feature)

http://codepen.io/galaxija737/pen/pHvEi
And here, this is working properly.

But then, I can't figure out how to integrate the js code properly into wordpress; whatever plugin i'm using. And idem into JSFiddle, impossible to run properly the script, as you can see...
https://jsfiddle.net/szan6shz/)

For instance using "TC-custom-javascript" plugin; when I add the JS code, nothing is running (i.e the drag-drop feature is not working; like ont the Fiddle) :

I'm really new at Javascript as you can see. If anyone can give me a hand on this. (I guess i miss something is the way JS needs to be written/integrated)

Thanks a lot !

Greg


Alfro on "script php stop inserting categories"

$
0
0

I have a php script taking categories from softonic.com, and im trying to insert them into my blog, but I have a few problems. The first of all, is that the categories are not with any link, so you can't click on them. Can look at it right here: http://www.softcnet.com As you can see in the main menu there are categories but you cannot click on them. But my main problem is my script is not inserting all the categories that it has to insert, and it doesn't throw any clear errors, so I'm not able to figure out where is the problem. In fact, the only error I have, and is thrown 570 times is this one:

Notice: Object of class WP_Error could not be converted to int in /route/wp-includes/post.php on line 2157.

I've seen my database in wp_term_relationships and there is 577 new entries and the error is thrown 570 times, so its thrown almost allways, but I don't know why because I've tested my code and it looks fine. I've looked at google for this error but haven't found anything useful. I need to fix this script because I can't run my next script if I don't have the categories fist.

here is my php script:

<?php
ini_set('memory_limit', '-1');
set_time_limit(0);
//Needed to create categories
include("../wp-admin/includes/taxonomy.php");

//Needed to create new posts
include ("../wp-load.php");

//Needed to create navigation menu
include ("wp-includes/nav-menu.php");

//display errors
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
libxml_use_internal_errors(true);

/**
Softonic bot to download categories/subcategories from softonic and insert/create them in SoftCnet
*/
//Bot to take categories from softonic
$url = array();

//Prepare categories array Url
$url[] = 'http://en.softonic.com/mac/categories'; //5685
$url[] = 'http://en.softonic.com/windows/categories';//5683
$url[] = 'http://en.softonic.com/android/categories';//5684
$url[] = 'http://en.softonic.com/iphone/categories';//5686
$url[] = 'http://en.softonic.com/web-apps/categories';//5688
$url[] = 'http://en.softonic.com/java/categories';//5689
$url[] = 'http://en.softonic.com/symbian/categories';//5690
$url[] = 'http://en.softonic.com/windows-phone-7/categories';//5691
$url[] = 'http://en.softonic.com/blackberry/categories';//5692
$url[] = 'http://en.softonic.com/windowsmobile/categories';//5693
$url[] = 'http://en.softonic.com/palm/categories';//5694
$url[] = 'http://en.softonic.com/pocketpc/categories';//5695

//Curl initialization
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEFILE, '');
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2450.0 Iron/46.0.2450.0 Safari/537.36');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//domDocument creation
$doc = new DOMDocument();
$temp_dom = new DOMDocument();
libxml_use_internal_errors(true);

/**
Create menu
*/

// Check if the menu exists and create it
$menu_name = 'Main Menu';
$menu_exists = wp_get_nav_menu_object( $menu_name );
if( !$menu_exists){

    $menu_id = wp_create_nav_menu($menu_name);
    $menu = get_term_by( 'name', $menu_name, 'nav_menu' );

}

/**
Create Apps category: need error handling, if category exist it throws an error!
*/
$pCat = wp_create_category('Apps');
$parent = wp_update_nav_menu_item($menu->term_id, 0, array(
        'menu-item-title' => 'Apps',
        'menu-item-object-id' => 0,
        'menu-item-db-id' => 0,
        'menu-item-object' => 'category',
        'menu-item-parent-id' => 0,
        'menu-item-type' => 'taxonomy',
        'menu-item-url' => 0,
        'menu-item-status' => 'publish',)
    );

/**
Create more parent
*/
$mpCat = wp_create_category('More',$pCat);
$moreParent = wp_update_nav_menu_item($menu->term_id, 0, array(
        'menu-item-title' => 'More',
        'menu-item-object-id' => 0,
        'menu-item-db-id' => 0,
        'menu-item-object' => 'category',
        'menu-item-parent-id' => $parent,
        'menu-item-type' => 'taxonomy',
        'menu-item-url' => 0,
        'menu-item-status' => 'publish',)
    );

$mainCat = array('mac','windows','android','iphone','web-apps','java','symbian','windows-phone-7','blackberry','windowsmobile','palm','pocketpc');

//create Apps category
//$id = wp_create_category('Apps');

//Retrieves all urls in url array and connect to them
foreach ($url as $key=>$link)
{

    if($key<=3){
        $mainParent=wp_update_nav_menu_item($menu->term_id, 0, array(
                'menu-item-title' => $mainCat[$key],
                'menu-item-object-id' => 0,
                'menu-item-db-id' => 0,
                'menu-item-object' => 'category',
                'menu-item-parent-id' => $parent,
                'menu-item-type' => 'taxonomy',
                'menu-item-url' => 0,
                'menu-item-status' => 'publish')
            );
        $pCat2=wp_create_category($mainCat[$key], $pCat);

    }else{

        $mainParent=wp_update_nav_menu_item($menu->term_id, 0, array(
                        'menu-item-title' => $mainCat[$key],
                        'menu-item-object-id' => 0,
                        'menu-item-db-id' => 0,
                        'menu-item-object' => 'category',
                        'menu-item-parent-id' => $moreParent,
                        'menu-item-type' => 'taxonomy',
                        'menu-item-url' => 0,
                        'menu-item-status' => 'publish')
                    );
        $pCat2=wp_create_category($mainCat[$key], $mpCat );
    }

    curl_setopt($ch, CURLOPT_URL, $link);
    $result = curl_exec($ch);

    //Creates Dom
    $doc->loadHtml($result);
    $xpath = new DOMXPath($doc);
    // libxml_clear_errors();

    //Do html query
    $classname = 'categories_group';
    $xlink  = $xpath->query("//*[contains(@class, '$classname')]");

    //Parse result
    foreach($xlink as $k=>$x)
    {

        //GET CATEGORIES
        foreach($x->getElementsByTagName('strong') as $key => $l)
        {
            $cat_name = $l->textContent;
            $id = createCategoriesNavMenu($menu,$mainParent,$cat_name);
            $mpsCat=wp_create_category($cat_name, $pCat2 );

        }
        //GET SUBCATEGORIES
        foreach($x->getElementsByTagName('li') as $key => $l)
        {
            $subcat_name = $l->textContent;
            createCategoriesNavMenu($menu,$id,$subcat_name);
            wp_create_category($subcat_name, $mpsCat);
        }
    }
}

//Set subCategory
function createCategoriesNavMenu($menu,$parent,$title){

    $id = wp_update_nav_menu_item($menu->term_id, 0, array(
            'menu-item-title' => $title,
            'menu-item-object-id' => 0,
            'menu-item-db-id' => 0,
            'menu-item-object' => 'category',
            'menu-item-parent-id' => $parent,
            'menu-item-type' => 'taxonomy',
            'menu-item-url' => 0,
            'menu-item-status' => 'publish')
        );
    return($id);
}
?>

drhur on "How to add jquery script?"

$
0
0

I would like to add this jquery script to remove p-tags around images:

$('p > a > img').removeAttr('height').removeAttr('width').parent().unwrap();

How do I make it work? How do I add the script? What do I need to do? Thank you for your help.

omii on "Best practice - Integrate data from remote site (API)"

$
0
0

Hello all,

Apologies if this isn't the correct forum for this but I'm a bit unsure on the approach to this.

The theme is entirely custom so any suggestions are all welcome, I have no real limits.

I'm attempting to make a live events site. I would like to use the standard build-in WP navigation system and pages to generate most of the site content.

The part that I'm unsure on the best practice of is to implement pages where I wish to display custom data. The data is being retrieved from a remote server. The data is for the events and the speakers and is constantly updated. The display of the data is locked in as well so the WP admin won't have any control over that data, or the display.

I only know of 2 ways at the moment..

1) Create a custom page template for every nav item (e.g. page-custom1.php .. page-custom999.php) and point every single link in the navigation their respective custom page, or perhaps append some URL data to a single custom page to tell it what data should be displayed.

2) Write a plugin (I'd rather not stick it in functions so I can re-use it) to add a filter and create a short code for the various API calls. Then point each navigation item to a standard page and insert the correct short code.

I feel like I might be missing a way of implementing this. The important parts are that I can use the standard WP navigation system just how it currently works, and the display of the remote APIs data is inside the current WP theme.

Any tips very much appreciated!

uncovery on "Creating the password-setting link by code"

$
0
0

When a asks for a password reset on wordpress, they used to get a password emailed (before 4.2 or 4.3 IIRC). Today, they are getting a link instead that allows them to set a password.

What is the way to create this kind of link with PHP?

Thanks!

LSOF on "HELP...I cant Login or find my WP-Admin??"

$
0
0

Hi Guys

I'm new to WordPress, for some unknown reason even to myself I thought it would be wise to modify my WordPress Address (URL), so I added /preview/demo to the end of my URL address.

Now... I can't even Login; my Username is being rejected and my email is also being rejected, and as you might imagine as a novice I am getting really panicked.

Can someone please help me... Thank you

Ed

Viewing all 8245 articles
Browse latest View live




Latest Images