Need Some Simple PHP Help Please

by 4 replies
5
Any help would be greatly appreciated. I'm a total php noob.

What I want to do is change the following code:

Code:
function syn_syndicate_box() {
    global $syn_multi_curl;
    $syn_multi_curl = new MultiCurl();

    $options = syn_get_admin_options();
    
    $post = wp_get_single_post( $_GET[ 'post_id' ] );
    $title = $post->post_title;
Specifically the $title part.

I want it to be able to post titles from a list of titles either sequentially or randomly.

I was going to use something like this:

Code:
$title[0] = "beginners php"; 
$title[1] = "random title example"; 
$title[2] = "quite neat i suppose"; 
$title[3] = "useful , probably not"; 
$title[4] = "oh well"; 
// get a random number 
$randomize = rand(0, 4); 
echo ($title[$randomize]);
But I didn't know if it would work inside the function section. I'd prefer it to just pull titles sequentially but if random is easier that's fine too.
#programming #coding #php #simple #wordpress
  • What exactly is the end goal that you are trying to accomplish? Do you really want to "echo" the titles like that? How is the syn_syndicate_box function being called? Do you want to loop through the list within each function call or do you want to move through the list once per call?
  • It remotely posts blog posts to other sites. I assume it's taking the content from my RSS feed. I'm trying to make the title have different keywords when it posts to these sites.

    As an example: My "POST TITLE" Keywords

    But I want it to be able to grab different keywords when it posts to each site. I don't know enough about PHP to even know what you mean by how it's being called. It's a WP plugin that I manually activate to post to the other sites.

    As far as the echo goes, I just found that on another site that talked about randomizing the title. I honestly don't even know what the echo function does.

    My PHP skills are trial and lots of error.
  • I just sent you a PM with some code and pseudo-code. For some reason I'm having trouble posting it here.
    • [ 1 ] Thanks
  • You should probably edit it in the post_title function that's more than likely in the post class. That function can return a random title, and then it can get set in the code you have in your post.

    If you still need help, PM me.

Next Topics on Trending Feed