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

nate.ads on "PHP function to change URL path"

$
0
0

Is there a function that can be created or a line of php code that can be used to maintain a page URL ending? An example of what I mean is lets say a english and french toggle. If my URL is http://sitename.com/en/cars if a user clicks the french toggle I would like the URL to refresh to http://sitename.com/fr/cars. This link is found in the header so it needs to output the same page ending each time.

I recall seeing something similar to this idea but I cannot remember the name or what it falls under.


FrankG2013 on "custom post type ordered by category (custom taxonomy) on a page"

$
0
0

Hello,

I would like to show my custom post type ordered by category (custom taxonomy)on a page, if possible also with the category name above the posts. But i dont know how i can do this. does anyone know the solution for this?

<?php $my_query = new WP_Query( $args = array(
'post_type' => 'cupcakes',
'taxonomy' => 'cupcake_category',
'field' => 'slug',
'terms' => 'specials')
);

$query = new WP_Query( $args ); ?>

<?php get_header(); ?>
<section id="primary" class="content-area">
<div id="content" class="site-content" role="main">

<?php if ($my_query-> have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title"></h1>
</header><!-- .page-header -->

<div class="archive-posts">
  <header class="entry-header">
	<h1 class="entry-title"></h1>
		</header><!-- .entry-header -->
			<?php /* Start the Loop */ ?>
<?php while ($my_query-> have_posts() ) : $my_query->the_post(); ?>

<?php get_template_part( 'content', 'page-cupcakes');?>

<?php endwhile; ?>

</div>
</div>
<?php snaps_content_nav( 'nav-below' ); ?>

<?php else : ?>

<?php get_template_part( 'no-results', 'archive' ); ?>

<?php endif; ?>
</div><!-- #content .site-content -->
</section><!-- #primary .content-area -->
<?php get_footer(); ?>

This is how it looks so far (this is a created archive-cupcake.php file)

Deexgnome on "Remove Toolbar for all user"

$
0
0

Hi there,

i would like to remove completely the Toolbar for all User and also Admins. I currently use a Plugin for that and would like to do this via Theme functions.

So i googled a bit arround and found some codes to disable it. But Sadly no one of it removed it.

Currently i tried

add_filter('show_admin_bar', '__return_false');
remove_action('wp_head', '_admin_bar_bump_cb');
show_admin_bar(false);

Dariusmit on "Hook for modyfying widget content"

$
0
0

Hello,

I am new with WP development and trying to create WP plugin.

The thing I need to do is to add a html tag buttons for default text widget with ready made html templates when the user press the button. I already got the buttons, but what I can't figure out what filter/action(or none of them) should I use to make that html template (for example <div></div>) to appear into wordpress text widget's content text field?

Thanks in advance!

Regards,
Darius

tstrebeck on "List Taxonomy name of item with 2nd tax filter"

$
0
0

I'm not even sure where to begin, or if what I'm requesting is possible. Here's the situation: I'm using a sermon plugin for a church website. (Sermon Manager). There are custom taxonomies for Series of Sermons, Service Types, Speakers, etc. I'm needing a way to display Series of Sermons that are from one of the Service Types. Is there a way to do this? I'm not even sure what the best route would be. Would there be a way to pull sermons from one Service Type tax, then filter the sermon series tax that are in those results? Let me know if more clarity is needed...

Ceyar on "Wp_query arguments strange problem."

$
0
0

Hello wordpress community!

I have a problem with my query argumentation. I use a custom fields text to output a value(a price) and this value is an String type. example value: "1500"

So, I would sort my post with a 'compare' => 'between'.

The code below display my post where price is between 450 and 900. But whe I want to set my argument to go in example from 450 to 1400, it won't display somthing more even if there are post with this prices.

When I use "between" with hundreds numbers it works fine. But when I use 1000 and above, it won't display anything.

Is there a problem because I use string with number inside?

$args = array(

		'post_type' => 'objets-a-louer',
		'posts_per_page' => '-1',
		'meta_query' => array(
			'relation'=>'AND',
			array(
			'key'     => 'obj_louer_loyer',
			'value'   => array( '450', '900' ),
			'compare' => 'BETWEEN',
						)
		),

	);

Thank you in advance!

gkopowski on "Woocommerce filtering shipping method in cart"

$
0
0

Hey! I want to remove or add some shipping options depending on the category of product that is in cart. For example: I have one product from category X and I want to add shipping-method-X to cart. And if I have one product from category X and one from another category, then shipping-method-X is disabled.

For now I have this code:

function check_product_in_cart($shipping_in_cart) {

$shipping_NAME = 'flat_rate';

global $woocommerce;

foreach ($woocommerce->cart->cart_contents as $key => $values ) {

			$terms = get_the_terms( $values['product_id'], 'product_cat' );
			$tmp = array();

			foreach ($terms as $term) {

				array_push($tmp, $term->term_id);
			}

			array_unique($tmp); // usuniecie duplikatow

			if (sizeof($tmp) > 1 AND in_array('49', $tmp)) {
				unset($shipping_in_cart[$shipping_NAME]);
			}
		}

return $shipping_in_cart;
}

add_filter('woocommerce_shipping_methods','check_product_in_cart', 10, 1);

Whats wrong with this code?

miked89 on "Adding Plugin Content above my posts"

$
0
0

Hi,

On my site http://www.gamertime.co.uk , I am looking to add a grid of 6 twitch.tv previews, so i can show people streams. I want to put this below my featured slider and before my "news section".

How can i impliment this?

I am not really sure where to start. I have tried to get images and such in that place but have only succeeded in adding text, but i cant remember how.

Basically, i would feature twitch streams, once clicked it would open in twitch not the site. I would use a plugin to get the streams and an online offline button there too. It can go other places, i would just like an idea how much work this would be.

Thanks in advance


skyscorcher on "db full of _transient_ records"

$
0
0

Hello, I have a huge problem with my website.

the database keeps filling up with records of type:

_transient_wc_product_children_13905
_wc_session_

I run a query to delete them, but the db keeps feeling with same records again.

Is there a way to find which part/plugin/theme/file causes the problem?

I guess this is hacked but I have no idea how to track this down.

It causes the site almost non-workable.

Thanks a lot in advance

joebudden1 on "Looking for plugin? Tags/database?"

$
0
0

I'm helping out on a website that crumbled by user-error & I'm looking for what could possibly be a plugin(?) that was lost.

Here is a screenshot of it before it was gone...
http://s11.postimg.org/3y8pdrfyb/tags_database.jpg

It's essentially a database of articles that can be searched by using the drop downs. This "database" is in the body of a page so I'm sure it must use the [tag]... I'm not even totally sure if this was using a plugin or not but none of these "articles" are posts within the wordpress. They open up separate pages from a "readarticle.php". Can someone help me decipher this? I'm out of my element on this one and just trying to figure out how I could build something like this/insert it into posts.

jorgitobg on "create custom post status do not update post_date_gmt"

$
0
0

Hi,

Im just creating a new custom post status:

--------------------------------------------------
function reviewed_post_status(){
register_post_status( 'reviewed', array(
'label' => _x( 'Unread', 'post' ),
'protected' => true,
'_builtin' => true, /* internal use only. */
'public' => false,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop( 'Revisadas <span class="count">(%s)</span>', 'Revisadas <span class="count">(%s)</span>' ),
) );
}
add_action( 'init', 'reviewed_post_status' );
--------------------------------------------------

Also I have added to post edit and quick edit screens without problems...

My problem is what after saving this new custom status "reviewed" wordpress update post_date and post_date_gmt, like this post were published or scheduled..... I need a custom post status before published or scheduled.

How can I make wordpress dont update post_date and post_date_gmt when this new custom status "reviewed" is saved?

I found a several documentation on how to hack core files, but I need other clean alternatives:

https://tharshetests.wordpress.com/2015/01/16/how-does-wordpress-know-if-a-pending-post-hasnt-been-published-yet/

Do you know how to do this like "edit flow" plugin?

Regards,

mlyczko on "Load script only if enabled in plugin options"

$
0
0

Hi

I want to have option in my plugin LOAD BOOSTRAP: yes/no, but i dont know how to get this option value and load or not load the script.

function widget($args,  $setup)
        {
            extract($args);
			global $bootstrap;
			$bootstrap = $setup['bootstrap'];
            echo $after_widget;
        }

function form($setup)
        {
            $setup = wp_parse_args( (array) $setup, array('title' => __('Some title', 'xxx'),
                'bootstrap' => '1') );
			$bootstrap = $setup['bootstrap'];

            ?>
            <div class="xxx-widget-options">
	            <p>
	                <label for="<?php echo $this->get_field_id('bootstrap'); ?>"><?php _e('Load Bootstrap', 'xxx'); ?></label>
	                <select name="<?php echo $this->get_field_name('bootstrap'); ?>" id="<?php echo $this->get_field_id('bootstrap'); ?>">
	                    <option value="1"<?php selected( $setup['bootstrap'], '1' ); ?>><?php _e('Yes', 'xxx'); ?></option>
	                    <option value="2"<?php selected( $setup['bootstrap'], '2' ); ?>><?php _e('No', 'xxx'); ?></option>
	                </select>
	            </p>
            </div>
        <?php
        }

function xxx_js(){
	if($GLOBALS["bootstrap"] == '1'){
		wp_enqueue_script( 'bootstrap.min', plugins_url() . '/xxx/js/bootstrap.min.js', array('jquery'), '3.2.0', false );
	}
}
add_action( 'wp_enqueue_scripts', 'xxx_js' );

bootstrap is undefined:/

Best Regards

coellefornia on "Parent Id"

$
0
0

Hi
my problem, how do I get the parentID of a page. I have two different menues and want to display the menues depending on the parentID. I ad a filter in the functions.php that works, but i can't get the parentID of the page, to use it an an if() statement. THX

shmk on "Endpoint with custom content/template"

$
0
0

Hello,
I have to create a plugin using endpoints (or rewrite rules) to make virtual pages (not manually created in the backend) having custom content coming from the plugin functions.

I looked at 'template_include' filter, but this template replaces all theme html (header, main content, footer...) and I'm looking to make the plugin not dependant from theme.

I've looked also at shortcodes, but these are inserted in pages made in the backend.

What is the correct approach to do this?

johnwiggity on "How to Link Display Name"

$
0
0

Hi I'm using this code to display the username in the top nav of my site.

add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
if (is_user_logged_in() && $args->theme_location == 'secondary-menu') {
$user=wp_get_current_user();
$name=$user->display_name; // or user_login , user_firstname, user_lastname
$items .= '<li style="color: #FFF;">Hi, '.$name.'';
}
return $items;

}

What I want to do is link the

Hi, '.$name.''

to the users account page. How would I go about doing that? Tried a simple hyperlink but didn't seem to work.

Thanks!


Guido on "Question about escaping data in the front end"

$
0
0

Hi,

I have 2 questions about escaping data in frontend of my website.

1) Should I escape a sprintf itself?

sprintf(__( 'Date: %s', 'mytextdomain' ), date_i18n( get_option( 'date_format' ), $date ) );

Currently I only escape the $date part:

$date = esc_html(get_post_meta( get_the_ID(), 'date', true ));

2) As displayed above, I escape the get_post_meta, should this be escaped?

Guido

mobdobber on "Passing Data Between Media Uploader Tabs"

$
0
0

Greetings everyone,

I have been banging my head on my desk today over this. I am trying to implement a new image editing option in the media uploader. I have the new tab displayed with the image editing plugin loaded. My issue is getting the attachment id over to this page to allow editing of it. I have also tried to reroute the Edit this image link in the attachment details that show up on the right of the media uploader after selecting an image. I have tried the filters media_row_actions, get_edit_post_link, attachment_fields_to_edit with no luck.

It looks like the Edit image link code is contained in media-template.php without any filters or actions in its vicinity so I think I am down to two options:

  1. Redirect the attachment edit image page.
  2. Use jquery to switch out the url to what I want.

Are there any suggestions for the proper way to do this?

Thanks a lot for any help!

lunchboxfl on "Add a daily cron job"

$
0
0

I have been given a cron.php from a company to add to my site to run once daily. How do I go about doing this in wordpress. I have looked at the wp_schedule_event, and wp-cron.php. It makes no sense to me. I just need to add for this cron.php that was given to me to run daily. Any help is greatly apprecited.

jgoug on "Woocommerce function to hide product ID from user ID"

$
0
0

I installed woocommerce on a site with a specific number of users who will be able to access the password protected store.

Q: is it possible to hide a product from all users EXCEPT for a few customers.
I would like to create a function that would be...

`hide product ID (from all) except for user ID: 93, 64, 22 etc.

Thanks in advance.

yanlantao on "first checkout, the project doesn't build"

$
0
0

I check out the latest IOS WordPress from Git. When I try to run the simulator, it gives three build errors as following. I will really appreciate it if anybody could answer it. my environment OS X El Capitan + Xcode 7.2 beta

-1- Diff: /../Podfile.lock: No such file or directory
-2- Diff: /Manifest.lock: No such file or directory
-2- the sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

Viewing all 8245 articles
Browse latest View live




Latest Images