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

chaos_cb7 on "View only domain name for links"


sNniffer on "Add argument in consultation"

$
0
0

Hey guys, a new project I have the following code to fill an option, which is running normally while listing all data.

<select name="agent_id" id="agent-selectbox">
	<?php
	$agents_args = array( 'post_type' => 'agent', 'posts_per_page' => -1 );
	$agents = get_posts( $agents_args );
	foreach ( $agents as $agent ) :
		?><option value="<?php echo $agent->ID; ?>" <?php if( isset($post_meta_data['themes_agents']) && ($post_meta_data['themes_agents'][0] == $agent->ID ) ){ echo "selected"; } ?>><?php echo $agent->post_title; ?></option><?php
	endforeach;
	?>
</select>

But, I would like to add a new parameter to query, tried adding via code, but does not work.

$agents_args = array( 'post_type' => 'agent', 'posts_per_page' => -1, 'id_usuario' => $user_id );

Recalling that the problem is not in my variable therefore contains the same data. Just do not know for PHP OO way.
 

simonp820 on "Edit comment notification emails"

$
0
0

Hi,

I'd like to be able to edit the content of the comment notification emails sent to a post's author when someone comments on their post.

Any ideas where I might need to look in order to do this?

Cheers

Ultic on "Nextgen - Galleries and thumbnails simulatanously"

$
0
0

Hello!

I'm using Nextgen Gallery version 2.0.65.
I have my albums/galleries displayed in the sidebar with the help from a short code. When I click on a gallery, the sidebar is replaced by the corresponding thumbnails, what is standard behavior.

What I would like to accomplish, is that when I click on a gallery in the sidebar, the thumbnails are displayed in the main page(instead of in the sidebar), and that the sidebars galleries remain as galleries(doesn't turn into thumbnails).

Any help will be appreciated.

All the best, cheers!

Howdy_McGee on "Adding Styles to TinyMCE 4.0 (WP 3.9)"

$
0
0

With the introductions of TinyMCE 4.0 comes a new, nice Format Select which has a few categories:

Headers
- Header 1 through Header 6
Inline
- Bold through Code
Blocks
- Paragraph through Pre
Alignment
- Left through Justify

What I want to do is add a Classes Menu at the bottom (below the Alignment menu) which I can stack classes in the submenu. If I use the old fashion method:

$style_formats = array(
	array(
		'title' => '.large',
		'block' => 'p',
		'classes' => 'large',
		'wrapper' => false,

	)
);
$in['style_formats'] = json_encode( $style_formats );

The above will override everything inside my formats menu. If I print out the variable $in - style_formats doesn't exist - formats on the otherhand does exist, but as a string. I tried to json_decode it but it was no use.

How do I add a "Classes" menu appeneded to the pre-existing formats?

Robodashy on "Database custom table issues - incorrect result displayed"

$
0
0

I tried to put code in the backticks like it says, so just ignore any ''s that look out of place (unless it's blatantly not me trying to do that)

First things first:
I've spent most of today going over these forums;
the stackoverflow forums;
the php.net manual; and
a bunch of random sites I found through Google Search - so,
if I've missed the answer and it seems like I'm asking an already answered question I'm sorry.
I've probably just been looking at the same problem for way too long and nothing is making sense.

The background:

We've inserted some custom tables into the wordpress database, so I can connect to these tables through $wpdb. The code for the working connections is as follows:

'global $wpdb;
// get list of localities
$localityRow = $wpdb->get_results( "SELECT * FROM tblYBSLocality ORDER BY Name ASC" );
// get list of schools
$schoolRow = $wpdb->get_results( "SELECT * FROM tblYBSSchool ORDER BY Name ASC" );
// get school ID if form has been submitted
$SelectedSchoolID = $_GET['schools'];
// get location ID if form has been submitted
$SelectedLocationID = $_GET['localities'];'

Then later in my page I make it do stuff (scorcery!)

'// Create a drop down box for the user to select their location (and one has been done for school but I left that out because you get the idea
<select name="localities" style="width: 300px">
<?php
foreach ($localityRow as $locality) {
$LocalityID = $locality->LocalityID;
$LocalityName = $locality->Name;
?>

<option value=<?php echo $LocalityID; ?> <?php if(isset($SelectedLocationID) &&
$SelectedLocationID == $LocalityID) print(" selected")?>><?php echo $LocalityName;?>
</option>
<?php
}
?>
</select>'

Note - Yes I know using * is bad, I'll fix that later - right now I just want it to work.

Using this I can then go through and generate a bunch of stuff using the following:

'// get school ID if form has been submitted
$SelectedSchoolID = $_GET['schools'];
// get location ID if form has been submitted
$SelectedLocationID = $_GET['localities'];'

This isn't really important to the rest of my issue, so I'll move on.

The issue:

I'll start with the code. This is supposed to connect to some other tables and do stuff - based on the connections and data retrieved above:

'$selectedSchoolName = $wpdb->get_results( "SELECT Name FROM tblYBSSchool WHERE SchoolID=".$SelectedSchoolID );
// get selected location name
$selectedLocationName = $wpdb->get_results( "SELECT Name FROM tblYBSLocality WHERE LocalityID=".$SelectedLocationID );
// get route ID
$getRouteID = $wpdb->get_results( "SELECT * FROM tblYBSRoute WHERE RouteID IN ( SELECT RouteID FROM tblYBSRouteSchool WHERE SchoolID =".$SelectedSchoolID.")".$SelectedLocationID);'

Now, I THINK the issue comes with the ".$SelectedSchoolID ); part (and the location one but this is already getting TLDR).

What I want to do later in the page (once the user has made their selections and submitted the form), is get results (fancy that!).

There are 2 parts to the results:

1st I want to say "Search results for routes between:" the location name and the school name.
2nd, I want to display those results. But I can't even get past the 1st point, so let's fix that first.

I have tried 3 different approaches:

'// FIRST APPROACH
// This kinda works, it echoes the last locality name from the table which is better than nothing
<b><?php echo $LocalityName;?></b> and <b><?php echo $SchoolName;?></b>

// SECOND APPROACH
// This gives me the white page of death. Which is hilarious because it's pretty much the exact same as what was used in the option - which worked
<b><?php if(isset($SelectedLocationID) && $SelectedLocationID == $LocalityID) echo $LocalityName;?></b> and <b><?php if(isset($SelectedSchoolID) && $SelectedSchoolID == $SchoolID) echo $SchoolName;?></b>

// THIRD APPROACH
// This also gives me the white page of death. And now I'm out of ideas.
<b><?php if(isset($SelectedLocationID) && $selectedLocationName == $LocalityName echo $LocalityName ;?></b> and <b><?php if(isset($SelectedSchoolID) && $selectedSchoolName == $SchoolName echo $SchoolName ;?></b>'

In my head (HAH!) the last 2 should work. Am I correct in thinking that it's the ".$SelectedSchoolID ); part? Or have I forked something else up entirely?

Sorry for the TLDRness, but I thought I should provide as much detail as possible.
Any and all help is greatly appreciated. I'm going to go smack my head into the desk a few times now :P

badincite on "Function to grab all images from page and display specific resolution"

$
0
0

I want to grab all images from a page and display them a specific resolution width="100" height="150" anyone have one?

NCCJon on "Search in CategoryDiv in Add new post"

$
0
0

Hi,

I have been doing a lot of research for this but cannot seem to find a solution. I need to add a searchbar to the admin Add New Post page in the Categories selection section (categorydiv), since I have hundreds of Categories, and it is impossible to find the right one with this long list.

Any suggestions?

Thanks!
NCC


dfaltermier on "How to add fonts to the Font Family menu in the WP visual editor?"

$
0
0

Hello gang,

I just upgraded to WordPress 3.9. As a result, I can no longer use the [visual editor] plugin Ultimate TinyMCE (http://wordpress.org/plugins/ultimate-tinymce/) to edit posts, pages, etc. It no longer works with WordPress v3.9 or greater. In it's place, I have installed WP Edit (http://wordpress.org/plugins/wp-edit/).

When I used Ultimate TinyMCE, I added a filter in my functions.php file to add fonts to the default Font Family drop-down menu in the WP editor. Here is the code snippet that I used:

/**
     * Override the default font-family loaded into tinymce editor. We did this
     * because we needed to add the 'Wendy' fonts.
     */
    function confit_child_register_tinymce_fonts( $settings ) {
        $settings['theme_advanced_fonts'] =
            'Andale Mono=andale mono,times;'.
            'Arial=arial,helvetica,sans-serif;'.
            'Wendy=wendy;'.            // Add our own @font-face font
            'Wendy Bold=wendy bold;'.  // Font from http://www.fontpalace.com/font-details/Wendy+LP+Bold/
            // (more are added here but excluded for brevity)
            '';
        return $settings;
    }
    add_filter('tiny_mce_before_init', 'confit_child_register_tinymce_fonts');

Now that I've switched to WP Edit, this filter no longer works. The array property 'theme_advanced_fonts' no longer exists. So, now I need to find a replacement method to do this.

Question: What is the correct WordPress way to add additional fonts to the Font Family drop-down menu? Do I still need to use the 'tiny_mce_before_init' filter in some way or some other?

I have searched through Google and the WP support forums but am not finding this topic addressed.

Thanks much.
David

PaulHaydock1982 on "Next / Previous links updating div content"

$
0
0

Hiya,

I'm trying to modify my current theme and I've run into an area thats got me stumped.

http://paulhaydock.com/

In my main blog box, I'm using the following code:

<!--POST SECTION-->
<div class="eslabout">
    <ul class="idTabs">
        <li>
            <a href="#news">
                Blog
            </a>
        </li>
    </ul>
    <div style="clear: both;"></div>
    <div id="news">
        <div class="subabout"  style="min-height: 485px">

Followed by the post etc...

What I want to do is create Previous and Next post buttons in the list were currently I have the word 'Blog'...and to load the content into the div without having to reload the page for the posts.

Anyone able to help / advise?

Thank you in advance,

Paul

etstinson on "Woocomerce adding single product info to category page"

$
0
0

I'm trying to highlight a single product at the top of my category page. I've added this code, which I just took from the content-single-product.php, to the archive-product.php file.

<?php
    	  global $product;

				/**
				 * woocommerce_before_single_product hook
				 *
				 * @hooked woocommerce_show_messages - 10
				 */
				 do_action( 'woocommerce_before_single_product' );
			?>

			<!-- BEGIN .main-item -->
			<section <?php post_class('main-item clearfix'); ?>>

			<?php
				/**
				 * woocommerce_show_product_images hook
				 *
				 * @hooked woocommerce_show_product_sale_flash - 10
				 * @hooked woocommerce_show_product_images - 20
				 */
				do_action( 'woocommerce_before_single_product_summary' );
			?>

			<div class="item-info">
        <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
        <div class="item-text">
          <?php  echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>
        </div>
       	<?php
          if($product->product_type != 'external')
          {
            //get form opening
            $params = array();

            if($product->product_type == 'variable')
            {
              $params = array( 'available_variations'  => $product->get_available_variations() );
            }

            woocommerce_get_template('single-product/form.php', $params);
          }
       	?>
      <div class="details clearfix">

        <?php
          //if product is variable type, show variants
          if($product->product_type == 'variable')
          {
            woocommerce_get_template( 'single-product/variants.php', array(
                                      'available_variations'  => $product->get_available_variations(),
                              			  'attributes'   			=> $product->get_variation_attributes(),
                              			  'selected_attributes' 	=> $product->get_variation_default_attributes()
                          		      ) );
           }
         ?>

         <?php
			     if ( ! $product->is_sold_individually() && $product->product_type != 'external' &&
                $product->product_type != 'grouped')
	 			   {
             woocommerce_quantity_input( array( 'min_value' => apply_filters(
                                         'woocommerce_quantity_input_min', 1, $product ),
                              				   'max_value' => apply_filters( 'woocommerce_quantity_input_max',
                                          $product->backorders_allowed() ? '' :
                                          $product->get_stock_quantity(), $product )
                          			               )
                    		  	            );
            }
          ?>

          <?php woocommerce_template_single_meta(); ?>

          <?php woocommerce_template_single_sharing(); ?>

          <?php
            /**
            * woocommerce_single_product_summary hook
            * @all default hooks removed
            */
            do_action( 'woocommerce_single_product_summary' );
          ?>

        </div><!-- .details -->

        <?php woocommerce_template_single_add_to_cart(); ?>

        </form>

        <?php do_action('woocommerce_after_add_to_cart_form'); ?>

			</div><!-- .item-info -->

			<?php
				/**
				* woocommerce_after_single_product_summary hook
		 		*
		 		* @hooked woocommerce_output_product_data_tabs - 10
		 		* @hooked woocommerce_output_related_products - 20
		 		*/
				do_action( 'woocommerce_after_single_product_summary' );
			?>

			<!-- END .main-item -->

			</section>

It works great when I view the store page, but when I go to a category page the description doesn't show up.

I would really appreciate some help.

Here's a link to the problematic page: Category

gucio666 on "How change media library tab?"

$
0
0

How change media library tab, because I would like to have default upload without tab. Thx. Maybe any spipped somebody have got.

Snaphaan on "Unserialize serialized data in wp_options"

$
0
0

I need to extract the data saved in my widgets from wp_options for comparisons and other uses. As far as I understand the data needs to be un-serialized and that is the function of get_option().

But I can't seem to do anything with the data.

The following code seems simple enough:

$text_widgets = get_option( 'widget_suidlanders_advertensies' );
	echo var_dump($text_widgets);

	foreach ( $text_widgets as $widget ) {
		extract( $widget );
}

The var_dump() throws out the following:

array (size=2)
  2 =>
    array (size=3)
      'title' => string 'Titel' (length=5)
      'text' => string 'Teks' (length=4)
      'textarea' => string 'Teks Area is hier		' (length=19)
  '_multiwidget' => int 1

How am I suppose to utilize this to make a comparison? If ($this == $that) etc.

stonylake on "get_the_content without url from embedded video"

$
0
0

For a kind of search function I need the posts text without html tags and without embeeded stuff.

Currently I use

$text = get_the_content('');
	$text = apply_filters('the_content', $text);
	$text = strip_shortcodes($text);
	$text = str_replace(']]>', ']]>', $text);
	$text = strip_tags($text);

It works so far, but if a posts contains embedded vidoes, there is the url of the video included in $text. This is undesired.

For example: get_the_content has

This is my dem video:
<video class="wp-video-shortcode" id="video-15-1" width="640" height="360" preload="metadata" controls="controls"><source type="video/mp4" src="pathtouploaded.mp4" />pathtouploaded.mp4</video>
Is it great?

After apply_filters, strip_shortcodes, str_replace, strip_tags it is

This is my dem video: pathtouploaded.mp4 Is it great?

But what I want is to get only

This is my dem video: Is it great?

Thanks for your help.

gucio666 on "How change order submenu in admin panel??"

$
0
0

I would like to change order in my submenu on admin panel. How can I change it? Thx for reply.


manex on ".mo files are not loaded in plugin"

$
0
0

Hi,
For some weeks I have been developing a plugin for my website, and as the website's content is in many different languages I thought I would do the same with the plugin. So, while I was developing I used the function __() to prepare it for the translation. This is an example of how I've been using it:

__("<em>some-text</em>","ohar-itzultzailea")

Once I have finished with the coding I have created the .po and .mo file using Poedit and in order to do a quick test I have translated that .mo file to en_US. The name of my two .mo files is ohar-itzultzailea-eu.mo and ohar-itzultzailea-en_US.mo . Both files are located in a folder called 'hizkuntzak', which is inside the main folder of the plugin.
In my plugin's main file I have added this function to load the appropiate .mo file.

function oi_itzulpenakKargatu()
	{
		load_plugin_textdomain( 'ohar-itzultzailea', false, dirname(plugin_basename( __FILE__ )).'/hizkuntzak/' );
	}

	add_action('init', 'oi_itzulpenakKargatu');

In order to test it I 've changed the WPLANG property in wp-config to make it load the translated file.

define('WPLANG', 'en_US');

However, when I test the plugin the translation is not loaded and I do not know why, I have been reading some tutorials on the Internet but no luck. According to what I found, I think the text the plugin shows is loaded directly from the code, and not from the .mo files, no matter what language. Any clue about what could be wrong?

Thank you very much for your help, :D

Manex

Christopher411 on "Admin form entry not showing on page"

$
0
0

I am a bit of a novice so bear with me.

I have an admin form for product lines and the entries on those forms show up together on a product page.

<div class="product_page_entry<?php if ($odd){ echo ' odd_product';}?>">
        <?php preg_match('/(<img[^>]*\/>).*(<a.*<img[^>]*\/><\/a>).*(<ul.*<\/ul>).*(<ul.*<\/ul>)/s', $content, $matches); ?>
        <div class="product_page_imgs">
            <?php
                $matches[1] = preg_replace('/-\d+x\d+\./', '.', $matches[1]);
                $matches[1] = preg_replace('/img/', 'img width="60" height="60"', $matches[1]);
                echo $matches[1];
                $matches[2] = preg_replace('/-\d+x\d+\./', '.', $matches[2]);
                $matches[2] = preg_replace('/img/', 'img width="200" height="60"', $matches[2]);
                echo $matches[2];
            ?>
        </div>
        <div style="width: 274px" class="product_page_ul">
            <?php echo $matches[3]; ?>
        </div>
        <div class="product_page_ul">
            <?php echo $matches[4]; ?>
        </div>
    </div>

The code takes the image and places it in column 1, the first ul and puts it in column2 and the second ul and puts it in column 3

How do I edit it to but the raw text I enter into the form below the images in the first column?

winock2014 on "widget with related post on a category and there tags"

$
0
0

i need a related post widget in my wp website, a widget with related posts from a categorie and the result of five posts with the permalink. After the title of the widget and befor the results i need a dropdown menu with the choice of the tags from the choosen categorie thats already showing 5 posts.

after clicking one of the tags the results should come in the same widget.

The code i have:

<?php query_posts('category_name=impressions&showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>

I do not need a ready to use widget because i use the php-code-widget, also there is no possibility for in example a tag cload, the point is that i use in my footer four times the same widget for different categories, each with there own tags...

I have no knowledge about PHP, i hope somebode can help me on this?

Patrick

Willbbz on "Disable plugin "inactive" in plugin editor"

$
0
0

When you edit a plugin within the editor and save it, it will sometimes change from

active -> inactive

This means any changes made in the editor are no longer applied after the file has changed to inactive.

Is there anyway to disable this as I like to do a lot of site editing while its live on my test environment.

Kassandra_P on "Change Sort Order of Image Attachment Pages"

$
0
0

Hi, I'll try to break this down as clearly as possible:

I have several galleries.
The images in each gallery are sorted (alphabetically by last name) according to the image slug.
When you click an image in the gallery, it takes you to the attachment page for that image.
The attachment pages also have navigation so you can cycle through them using previous_image_link / next_image_link

My problem is that the attachment page navigation cycles through the pages in order of date uploaded, rather than by slug like the galleries.

So, how can I sort my image attachment pages by slug?

I'm terrible at php, but I've researched it and it looks like I'll need to create a new WP_Query for attachments. Something like this?

$attachment_navigation = new WP_Query(
array(
    'post_type' => 'attachment',
    'post_parent' => null,
    'post_mime_type' => 'image',
    'post_status' => 'inherit',
    'orderby' => 'slug',
    'order' => 'ASC',
    )
);

From what I've read though, orderby slug doesn't work -- what should I use instead?

And then -- what else? Do I have to write another function to put it into effect? PHP newb here...

Thanks for your help!

Viewing all 8245 articles
Browse latest View live




Latest Images