Forum Replies Created

Viewing 15 replies - 1 through 15 (of 29 total)
  • Thread Starter phpchick

    (@phpchick)

    anybody?

    Thread Starter phpchick

    (@phpchick)

    I figured it out.

    I didn’t put the $page variable, back into the $args array

    the corresponding part should have looked like this

    $args = array(
    	'posts_per_page' => 3,
    	'post_type'=> 'post',
    	'category_name' => 'premium-news-updates',
    	'paged' => $paged
    );
    Thread Starter phpchick

    (@phpchick)

    It was working, the culprit was that I was editing the header file from the original wordpress installation and not the current one that I was trying to modify

    Thread Starter phpchick

    (@phpchick)

    I’m calling it from the same file from which the header-member.php file is located.

    The files in the wordpress installation are a copy from another instance, will that make a difference?

    If so, where does one edit the file path from which the get_header function gets the path?

    Thread Starter phpchick

    (@phpchick)

    looks like you have to include the wp-config.php file, which is what I added:

    include “../public_html/wp-config.php”;

    Thread Starter phpchick

    (@phpchick)

    Found it Andrew, but when I go in there, the value looks like this…

    a:2:{i:2;a:41:{s:5:”title”;s:18:”Last 5 Predictions”;s:7:”symbol1″;s:4:”KORS”;s:7:”symbol2″;s:4:”GMCR”;s:7:”symbol3″;s:4:”MSFT”;s:7:”symbol4″;s:1:”M”;s:7:”symbol5″;s:4:”LULU”;s:6:”price1″;s:5:”48.34″;s:6:”price2″;s:5:”17.92″;s:6:”price3″;s:5:”32.87″;s:6:”price4″;s:5:”35.87″;s:6:”price5″;s:5:”58.98″;s:12:”shortsymbol1″;s:3:”TIF”;s:12:”shortsymbol2″;s:3:”KSS”;s:12:”shortsymbol3″;s:3:”BKS”;s:12:”shortsymbol4″;s:4:”LQDT”;s:12:”shortsymbol5″;s:4:”DECK”;s:11:”shortprice1″;s:5:”60.34″;s:11:”shortprice2″;s:5:”60.87″;s:11:”shortprice3″;s:5:”20.28″;s:11:”shortprice4″;s:5:”32.87″;s:11:”shortprice5″;s:5:”60.83″;s:4:”cat1″;s:11:”Sales Accel”;s:4:”cat2″;s:11:”Competition”;s:4:”cat3″;s:7:”Surface”;s:4:”cat4″;s:11:”Holiday Str”;s:4:”cat5″;s:11:”Sales Accel”;s:9:”shortcat1″;s:14:”Sandy Exposure”;s:9:”shortcat2″;s:11:”Macro Conce”;s:9:”shortcat3″;s:10:”Nook Decel”;s:9:”shortcat4″;s:13:”Decel Traffic”;s:9:”shortcat5″;s:8:”Ugg Risk”;s:5:”date1″;s:5:”11/16″;s:5:”date2″;s:5:”11/16″;s:5:”date3″;s:5:”11/17″;s:5:”date4″;s:5:”11/17″;s:5:”date5″;s:5:”11/20″;s:10:”shortdate1″;s:5:”11/15″;s:10:”shortdate2″;s:5:”11/08″;s:10:”shortdate3″;s:5:”11/20″;s:10:”shortdate4″;s:5:”11/17″;s:10:”shortdate5″;s:5:”11/18″;}s:12:”_multiwidget”;i:1;}

    How in bloody hell does one take that and turn it into something nice to work with? There must be some short cut?

    Thread Starter phpchick

    (@phpchick)

    Solved!

    I removed the quotes.

    $objYahooStock->addStock($stocksymbol);

    Thank you everybody for so much help ??

    Thread Starter phpchick

    (@phpchick)

    One more issue

    $objYahooStock->addStock(“$stocksymbol”);

    That line is getting read as $stocksymbol
    What do I have to do change in order to make it read the variable, as opposed to $stocksymbol?

    I’ve tried wrapping in braces like

    $objYahooStock->addStock(“{$stocksymbol}”);

    but it did not work

    Thread Starter phpchick

    (@phpchick)

    UGH.

    The directory starts in the plugin root and NOT the directory that the file is located in.

    I changed
    include_once(‘class.yahoostock.php’);
    to
    include_once(‘prediction-widget/class.yahoostock.php’);

    and now it works. ARGH

    Thread Starter phpchick

    (@phpchick)

    One last question,

    function widget($args, $instance)
      {
    
      function getstockstats($stocksymbol)
      {
    	include_once('class.yahoostock.php');
    	$objYahooStock = new YahooStock;
    	$objYahooStock->addFormat("snl1d1t1cvc1p2");
    	$objYahooStock->addStock("msft");
    
    	foreach( $objYahooStock->getQuotes() as $code => $stock)
    {
        ?>
        Code: <?php echo $stock[0]; ?> <br />
        Name: <?php echo $stock[1]; ?> <br />
        Last Trade Price: <?php echo $stock[2]; ?> <br />
        Last Trade Date: <?php echo $stock[3]; ?> <br />
        Last Trade Time: <?php echo $stock[4]; ?> <br />
        Change and Percent Change: <?php echo $stock[5]; ?> <br />
        Volume: <?php echo $stock[6]; ?> <br /><br />
        <?php
    }
    
     if ( $stocksymbol == "aapl" ) {
    	$result = "Test!<br />";
    	echo $result;
    }
      }
    
    getstockstats("aapl");
        echo $after_widget;
      }

    Why doesn’t my function work when I add the echos inside that foreach loop? I have a feeling it is some sort of permissions issue but am not sure

    Thread Starter phpchick

    (@phpchick)

    I changed to this,

    function getstockstats($stocksymbol)
      {
     if ( $stocksymbol == "aapl" ) {
    	$result = "Test!<br />";
    }
    echo $result;
      }

    and it worked. But shouldnt returning $result also print it out?

    Thread Starter phpchick

    (@phpchick)

    whats the difference between echo and return ?

    All I wanted to do was print “yourname is some guy”

    Thread Starter phpchick

    (@phpchick)

    Just want to follow up. I solved the problem and I did it by adding these lines

    global $paged, $wp_query, $wp;
    $args = wp_parse_args($wp->matched_query);
    if ( !empty ( $args['paged'] ) && 0 == $paged ) {
      $wp_query->set('paged', $args['paged']);
      $paged = $args['paged'];
    }

    I added them right before these lines

    $wp_query = new WP_Query( $args );    //these 3 $wp_query use to be "$the_query"   --  when you change these to wp_query, it seems to enable the wp_paginate
    		while ( $wp_query->have_posts() ) : $wp_query->the_post();

    and the reason is this

    “$paged (it doesnt matter if you make it global and access via the variable $paged or you use get_query_var(‘paged’) always resolves to 0.
    The /page/2 matches the correct rewrite rules.

    matched_rule: page/?([0-9]{1,})/?$
    matched_query: index.php?&paged=$matches[1]
    matched_query (evaluated): &paged=2

    but, $paged is 0 no matter what.”

    And I found the above (and the solution), here https://wpquestions.com/question/show/id/701

    And then, to get wp_paginate working properly (it was showing every post on the same page, while looping the html over and over again),

    I added wp_reset_query immediately following the code for wp-paginate, like so

    <?php if(function_exists('wp_paginate')) {
    	    wp_paginate();
    	}
    			wp_reset_query();
    	?>

    Thanks for all the help alchymyth x0x0

    Thread Starter phpchick

    (@phpchick)

    So using that snippet causes at least the link “older entries” to show up.

    When you click on it however, it goes to url.com/page/2/ but all the stories are the same as the first.

    In addition, the link on ‘page/2’ is a link to itself, ‘page/2’ if that makes sense.

    Thread Starter phpchick

    (@phpchick)

    Just want to follow up so others can use the code if they need help.

    I was able to fix the code thanks to esmi and here it is

    add_filter('query_vars', 'geturlvar' );
    function geturlvar( $qvars )
    {
      $qvars[] = 'sector';
      return $qvars;
    }
    
    $args = array(
    	'post_type' => 'earnings', // use to be stock
    	'posts_per_page' => 3,
    	'offset' => $_GET['offset'],
    	'meta_query' => array(
                array(
    			'key' => 'sector',
    			'value' => $_GET['sector']
    			))
    );

    Thank you so much esmi! <3

Viewing 15 replies - 1 through 15 (of 29 total)