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

Mads Phikamphon on "Handling a huge amount of $wpdb->get_results data"

0
0

Hi,

Have a $wpdb->get_results call like this:

$currentProductsArray = array();
$currentProducts = $wpdb->get_results("SELECT id, feedid, size, price FROM products WHERE shopid = $shopid");

Everything is fine if a shop just have a few thousand products, but some shops have 100,000+ products => the array gets huge and causes the script to crash.

Anyone got an idea for saving the results of $wpdb->get_results in a smaller data structure than the standard PHP array?

Thanks,
Mads


jchavez95 on "Need help with my Category background"

0
0

I have this problem and i can not find a solution

I can not change my background image or color in this page
https://infeticworld.com/category/bloginfetic/

I think because this is category and it is not a page. But i really don't like the white background help me to change it please!

forevangel23 on "Custom post type + Featured image + Loop + Lightbox"

0
0

Okay, so I am currently working on a custom plugin (my first ever attempt) for my own site. However, I've come upon an issue that has me stumped.

I want to take the featured image from a custom post type, and make it the background of a div, and when that div is clicked on, I want the image to show up in a lightbox (I'm currently using Lightbox2).

I want this all to be in a loop, so that I can have this happening for all of the posts in my custom post type.

Thank you in advanced.

Pt on "Prevent   characters from getting removed by the visual editor"

0
0

I'm a graphic designer and want my   (non-breaking space) characters to stay where I bloody-well put them without the visual editor stripping them out again. If you're a typography dick like me, this is handy to make two or more specific words wrap together rather than breaking at the spaces.

For example, if you want "South Australia" not to break in an address.

So, I wrote added a simple shortcode via my child-theme's functions.php:

//[nbsp] shortcode
function nbsp_shortcode( $atts, $content = null ) {
	$content = '&nbsp';
	return $content;
}

add_shortcode( 'nbsp', 'nbsp_shortcode' );

Then I just use:
[nbsp]
Instead of:
 

Hope this helps someone.

Pt.

jjansen1609 on "NextGEN Gallery not displaying gallery page with link"

0
0

I am trying to display 8 small thumbnails on my home page. When I click on any of the thumbnails I want to go to my full gallery page showing all my images. I thought that using the shortcode "show_all_in_lightbox=1" might have done that. It doesn't. "=1" or "=0" give me exactly the same results which is to show a single image. Is there any way that I can get to my full gallery page with all my thumbnails when I click on a single picture. The full code that I was using was:
[ngg_images gallery_ids=3 display_type=photocrati-nextgen_basic_thumbnails disable_pagination=1 override_thumbnail_settings=1 thumbnail_width=100 thumbnail_height=75 number_of_columns=4 images_per_page=8 show_all_in_lightbox=1]

I also tried coding a link to the gallery page URL around this and that doesn't work. When I click on a thumbnail I still open up that single image.

Any suggestions very much appreciated.

sjiamnocna on "Plugin translations"

0
0

Hi! I'm developer of plugin and I also provided language files (.po and .mo) for czech translation. Now, when theres Glotpress (web translations) I want to use it to let people translate, but I also want to import my Czech translation into it. Is there any simple step to import the translation?

I also tried translating my readme.txt with the app, but I can only "suggest" translation. Is there way to let plugin's author correct and accept the translations?
I want to correct and accept all translations myself, becouse WP Developers (or whoever is in charge of accepting translations) aren't interested in having my plugin translated (especially to czech) and it's only waste of time

dacano_1990 on "Add +6 Hours to current_time('mysql')?"

tabithatomsin on "Help: Set cookie in wordpress for current user info."

0
0

0
down vote
favorite

I'm trying to add a chatroom to our wordpress site. The company that we purchased the chatroom software from is doing a couple custom additions for us. For one of the additions they asked that we set a cookie to collect current user data.

I apologize, I'm extremely new to PHP so please be gentle!

For example, to collect User-ID number, I've tried adding this to our function.php file:

$current_user = wp_get_current_user();

add_action( 'init', 'my_setcookie' );
function my_setcookie() {
   setcookie( 'id', $current_user->ID, 3 * DAYS_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
}

This is not producing anything when I look at the cookies being collected in my browser.

This seems to be a very opaque topic, as I've not found much information about it online.

Is there a way to set a cookie to collect current user data?

Thank you!


denhen89 on "Replace or delete old user role when getting a other user role"

0
0

Hello,

i`m using Easy Digital Downloads + Frontend Submissions plugins to create an multivendor marketplace and i have this problem:

I want to set up 3 different Menus: One Menu for "guests", One for "subscriber" and one for "Frontend Vendor" user role.

This i can do with the "Nav Menu Role" plugin, but the problem is, if a subscriber registers as vendor and gets the Frontend Vendor, then he still has also the Subscriber role, so he has 2 roles and a vendor still see the Menu for subscriber user role.

Of course this works well when a Subscriber is just an Subscriber, or if a user registers straight as Vendor, then he has only the Frontend Vendor and can see the Menu for the Frontend Vendor user role.

So there a 2 options to avoid this problem:
OPTION 1: Some function which replaced the old user role with the new one instead of just adding a addional role.

OPTION 2: Adding a HIDE MENU / HIDE MENU ITEM for specific user role function to the Nav Menu Roles Plugin.

Unfortunately (what i really don`t understand) Nav Menu Roles plugin and all other similar plugins, has only this functions: SHOW for logged out users, SHOW for logged in users or SHOW for specific user role, BUT NOT a HIDE for specific user role.

PLEASE HELP ME! :D

cjones81 on "Sticky Post from Frontpage (homepage)"

0
0

My website Dailyroe.com is a news aggregation website that Links to National & International News sources. DailyRoe.com automatically fetches recent news stories for a wide variety of news sources and publishes the link to that story under the "Unmaintained LIVE Feeds..." section on the homepage..

Above that is a section where i'll sticky the stories that i feel that deserves more attention.

I would like a Link next each of the stories under the "Unmaintained LIVE Feeds..." section that only i can see that says Sticky. When i click that link, it stickies that story.

Anyway to achieve this?

remilatignasse on "Add a media queries to disable some javascript files"

0
0

Hello all,

I explain myself, i'm working on a child theme and I load my javascript files in function.php.

I want to disable some javascript and load another when the website is on tablets or mobile.

Can you tell me how to do that ? I'm a newbie.
Thank you

This is my functions.php for the moment.

<?php

function theme_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

function scrollmagicjsenqeue() {
	wp_enqueue_script( 'child_theme_script_handle', get_stylesheet_directory_uri() . '/js/scrollmagic.js', array( 'jquery' ),'1.0.0',true );
}
add_action( 'wp_enqueue_scripts', 'scrollmagicjsenqeue' );

function idjsenqeue() {
	wp_enqueue_script( 'id_contraire', get_stylesheet_directory_uri() . '/js/id-contraire.js', array( 'jquery' ),'1.0.0',true );
}
add_action( 'wp_enqueue_scripts', 'idjsenqeue' );

function flexsliderjsenqeue() {
	wp_enqueue_script( 'flex_slider', get_stylesheet_directory_uri() . '/js/jquery.flexslider.js', array( 'jquery' ),'1.0.0',true );
}
add_action( 'wp_enqueue_scripts', 'flexsliderjsenqeue' );

function mousejsenqeue() {
	wp_enqueue_script( 'mouse_wheel', get_stylesheet_directory_uri() . '/js/jquery.mousewheel.min.js', array( 'jquery' ),'1.0.0',true );
}
add_action( 'wp_enqueue_scripts', 'mousejsenqeue' );

DenisCGN on "Get exact CPT from the authorID"

0
0

Hello,

I need some help to get the exact 1 CPT "artist" URL from an author ID.

The goal is to change the author_link to this custom post type "artist" of the author.

I allready got the author ID and I know how to change the author link by using the author_link filter.

So, how do I get the custom post type "artist" URL where the author ID is $global ID.

I know I can do this by customize a query, but, cause there is only ONE cpt for each author I am looking for some shorter way to get this URL or PERMALINK.
die
Thanks for help,
Cheers,
Denis

suntower on "Redirecting links to Draft Posts to custom page"

0
0

My users create posts with links to future posts which are in Draft status. We use Post Name as our permalink structure.

As usual, when these users click such links they are directed to the Drafts for editing. Eg.

<a href="/future-draft-post">Here is our next fantastic post!</a>

And also as usual, when non-logged-in users click such a link they get a 404.

What I want is for non-logged-in users to click such a link and instead of getting a 404 be redirected to a custom page that says 'Coming Soon!'

How do I do that?

willfretwell on "Front End Custom Taxonomy Editing"

0
0

Hello,

I have added the custom taxonomy "Campaigns" to my site, which I use as another version of Tags. I have created a page where the Campaigns can be created, but I am struggling to create a dropdown menu (hopefully with a search function) of the campaigns that have been created which can then be assigned to a post, I was hoping to have this at the end of each post so that the logged in users can assign their campaigns to a post without going to the back-end as they will be subscribers.

I hope somebody has any help to offer

Kind Regards,

Prasobh on "Display Wordpress dashboard on a page/post"

0
0

Hi,

How we can display 'wordpress dashboard'on page without left sidebar (left options/menu). Just want to display admin panel content on a page.

Any help?

Thanks


Fact Maven Corp. on "Remove rules from .htaccess through a plugin"

0
0

I've been able to add custom rules to my .htaccess through my plugin using the following function:

add_action( 'init', 'dsbl_htaccess' );

function dsbl_htaccess() {
            require_once( ABSPATH . '/wp-admin/includes/misc.php' );
            $rules = array();
            $rules[] = '<Files xmlrpc.php> # Disable XML-RPC';
            $rules[] = 'Order allow,deny';
            $rules[] = 'Deny from all';
            $rules[] = '</Files>';
            $rules[] = '';
            $rules[] = '<Files wlwmanifest.xml> # Disable Windows Live Writer';
            $rules[] = 'Order allow,deny';
            $rules[] = 'Deny from all';
            $rules[] = '</Files>';
            $htaccess_file = ABSPATH . '.htaccess';
            insert_with_markers( $htaccess_file, 'Fact Maven', ( array ) $rules );
        }

As a result, the following is added to the .htaccess:

# BEGIN Fact Maven
<Files xmlrpc.php> # Disable XML-RPC
Order allow,deny
Deny from all
</Files>

<Files wlwmanifest.xml> # Disable Windows Live Writer
Order allow,deny
Deny from all
</Files>
# END Fact Maven

However, I'd like to know how I can have these rules removed once the the plugin is deactivated. After doing some research online, I'm aware that I would have to use the register_deactivation_hook hook which will run a function when I deactivate a plugin.

But after that I am still lost on trying to figure out where to go after that. If someone could provide me with some guidance, I would appreciate it.

morgyface on "The forced crop of medium sized images"

0
0

Before anyone tells me this question has been asked and answered before and points me back to a seven year old post hear me out.

I'm currently using this code:

if( false === get_option("medium_crop") ) {
    add_option("medium_crop", "1");
} else {
    update_option("medium_crop", "1");
}

Which does work to force crop any images to the exact medium sized dimensions as specified in the dashboard settings. I'm assuming all this does is change the medium_crop option in the database from a zero to a one.

However if you then decide you no longer want medium images cropped and remove this snippet from your functions.php file it will not stop-the-crop as the one in the database remains.

In order to do that you'll need to amend the code to this:

update_option("medium_crop", "0");

I'm asking you wp guru types if there's a more robust way of doing this? So upon delete of the snippet cropping ceases.

Madyson on "Join Page Redirect"

0
0

When someone visits the website and clicks on something such as the resources page containing videos and realizes they haven't logged in or signed up. Once they have signed up or logged in instead of being directed to the home page, can they be taken back to the page they were previously on? If so how can this be done? I am not a developer so was hoping for a simple solution to this or for someone to guide me through a process allowing for this to happen.

monkeybrain on "Custom Taxonomy get most recent item of sub categories"

0
0

Good Day,

I'm creating my own little photo gallery plugin.
I've created a custom post type 'photo' and a custom taxonomy 'gallery'.
When I browse to /photo/ the archive-photo.php returns the list of all galleries using this query:

<?php
//for a given post type, return all
$post_type = 'photo';
$tax = 'gallery';
$tax_terms = get_terms($tax);
$tax_link = get_term_link($tax);
if ($tax_terms) {
  foreach ($tax_terms as $tax_term) {
    $args=array(
      'post_type' => $post_type,
      "$tax" => $tax_term->slug,
      'post_status' => 'publish',
      'posts_per_page' => 1,
      'orderby' => 'menu_order',
      'order' => 'ASC',
      'caller_get_posts'=> 1
    );

    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>

This then links to /gallery/category1/ where taxonomy-gallery.php lists all items within that category1.

This works fine. But now I'd like to make it work with subcategories. So that when I visit /photo/ it only returns top level categories and when I visit /gallery/category1/ and 'category1' has subcategories it lists those subcategories like archive-photo.php does with top level categories.

--------------
Now I've got three questions:

1. I'd like to have the query above in archive-photo.php only return the top level categories. Is there an argument for the query similar to ($parent->term_id=="") I could use?

2. I thought to edit taxonomy-gallery.php with something like

if((sizeof($children)>0)) { // has child
    get_template_part( 'parts/photo-galleries-overview');
}
else {
    get_template_part( 'parts/photo-gallery-items');
}

What would that code exactly look like?

3. For 'parts/photo-galleries-overview' I'd need a query that returns the first item of each subcategory within the current category. Similar to the query above (1.) but instead of returning top level categories, it should return only the subcategories of the current category.

Something like 'child_of' => $current_term->id, or something like $tax_terms = get_terms($tax, array('child_of' => $current_term->id));
Where as $current_term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ), get_query_var( 'id' ) );

I'm more of a design/front-end guy with basic understanding of php. So any help with working code snippets would be very much appreciated.

Also, is this too much to ask for? Should I hire someone to help me with this?

Thanks a lot

TIEro on "How to display wp-editor word count?"

0
0

I'm using the built-in wp-editor for a post submission screen (custom post type), so I fiddle with TinyMCE for custom buttons. I'd like to have the word count show on the status bar, but can't find how to do it. I've hunted all over the place!

My code is simple (I've removed a bit of surround <div> stuff, and $sub_content is the content in the editor):

$args = array(
    'media_buttons' 	=>	false,
    'textarea_rows'		=>	25,
    'tinymce'		 	=>	array ('theme_advanced_buttons1' => 'bold,italic,|,bullist,numlist,|,spellchecker','statusbar' => true)
);
wp_editor($sub_content, 'sub_content', $args);

I assume I need another parameter in the $args, but can't find any reference to what I need.

Any help appreciated!

Viewing all 8245 articles
Browse latest View live




Latest Images