Request to appending more data to existing data - javascript

Please this question is just a request for guide. No coding had been started yet but based on recommendations, I will begin the coding. I am still new to JQuery.
I want to load all my blog posts using JSON API plugin. I have been able to create the code to load the posts and limit it to just 3 posts out of 11 posts.
I just want to know what the best approach or sequence is to add a link so when someone clicks on it, it then looks through the already displayed posts, checks for the last posts and then appends the next 3 posts until all 11 posts had been displayed before it either hides the Load more link or greys it out.
Please I just need someone who had done something similar to this to advise on the sequence to use.
Create a Load function to load the first 3 posts and store in a div (id=postcontent)
Create a click function that on clicking a class element (.loadmore), checks content of existing div (id=postcontent), does a count, compares the count to total of posts in json data (11), then looks for last post and appends another 3 posts and does a refresh to maintain the markup

Related

wp_insert_post not displaying posts until hit update in the editor

I am creating a plugin for a theme am using the theme has multiple fields and i field them all using both custom data and fields.
But i am missing something, the plugin creates multiple posts using wp_insert_post Function
but only 1 or upto 3 posts will display in the theme, and if i click update to 1 post on the wordpress editor all the posts show at once as if fixed but there is no additional fields added to the posts meta fields so am confused.
I checked the cache, also when i disable the theme and enable it again all the posts show up so where is the issue coming from and how do i fix this.
Please Help, much appreciated.
After a Long Struggle i had to read the theme Structure and how it displays its posts and inserts them and found that they have been submitting the posts id's in a file.
So how it works is
when you load the post page the theme requests for posts from file it checks if file exists and time last updated and if time last updated post in database and time last updated file are the same it displays the post id's inside the file.
Conditional Else it updates the file and add the posts id's currently in the database inside the file.
So basically the theme doesn't sort posts directly from the database but file So?
I changed the theme display and make it request Directly from database.
I can't believe it's a very popular theme with a messy code structure.
Well that's all hope it helps those who face same problem.
Else you can ask in this thread i will help if i am able to i am not expert but have been coding for 4 years and still get frustrating bugs like this and it could be that i am impatient eitherway, Jaa :)

How to prevent divs created when form is submitted from disappearing when form is resubmitted

I have been struggling with this one problem for about 5 days now and I have tried many different things but have not made any progress. Can someone please help me to find a solution?
Here is a video showing what my page does currently
https://imgur.com/a/DmkP0ut
What is happening is the user inputs some text into a form which checks for records in a database and creates rows with the info taken from that database. Then when the user ticks the checkbox it will append the row to another div. The problem is that when the user searches another name the rows that have been selected disappear.
I would like for these rows to stay where they are then when the user continues to the next page I would like the info in the selected rows to carry over to the next page.
I have tried many different approaches including cloning the rows, saving the ID as a session variable and attempting to retrieve info for that ID from the database again, and saving the individual names as making the divs from scratch. I am not even sure which approach is the right one let alone how to do it.
I know I have not really given a lot of information but I really don't know what code is important, so if you need any more information just ask.

Randomize google forms sections with Gsuit?

I need to randomize the SECTIONS (not questions) in my google form. The reason I need to do sections is because every section corresponds to a video so each needs to be a section.
This is the closest thing I've gotten to a solution:
https://developers.google.com/apps-script/reference/forms/page-break-item
// Create a form and add three page-break items.
var form = FormApp.create('Form Name');
var pageTwo = form.addPageBreakItem().setTitle('Page Two');
var pageThree = form.addPageBreakItem().setTitle('Page Three');
// Make the first two pages navigate elsewhere upon completion.
pageTwo.setGoToPage(pageThree); // At end of page one (start of page two), jump to page three
pageThree.setGoToPage(FormApp.PageNavigationType.RESTART); // At end of page two, restart form
I've already made the form and don't want to remake it (so many questions, so many videos). If I could use the .setGoToPage function shown above I think I could find a solution to randomize the sections aka pages. I just don't know what the names of my already existing pages are or how to find them. Please help!!!!
As you noticed yourself the methods applicable to a page are very limited
So, while you can add a page break, you cannot retrieve it in a subsequent code execution, and thus there is no way to shuffle it.
There is also no way to retrieve or set the questions belonging to each page in order to create new pages with questions on each script execution.
You have the possibility to file relevant feature requests on Google's Public Issue Tracker, chances are they will be implemented in the future if enough users show interest
In the mean time, as a workaround the only 2 things I can come up with is
a) Duplicate your form, shuffle the pages manually from the UI for each duplicate, create a WebApp that will arbitrary redirect the user to one of the URLs of the different form versions
b) Summarize all questions belonging to one page / section into one question item - it is easy to shuffle opposed to pages
In case it's helpful - further information:
How to shuffle questions each time a form is submitted
How to shuffle questions on time-driven trigger

Getting images from wordpress post and showing through Javascript

I've been working on a webcomic website for a while now but for a few weeks now I've been stuck on the comic viewing part.
In theory, what I'm trying to do is grab images from the WordPress post and store them in a PHP Array variable and show 1 element of the Array at a time through Javascript.
Can anyone help out?
Since many details are not mentioned I will try to answer as best as I can from whatever you have mentioned.
In case I have access to theme functions I will try to get the post attachments as array of URLs and render them wherever I want to with the help of slider to achieve one image at a time. In case I am not able to extract the post attachments I will get the url of post, get the html crawl to container which holds the post content and extract the image tags and display them where ever I want to again with the help of slider

How can I scrape the next page in this DOM where the a tags have no links?

I'm currently learning how to do web-scraping with python and beautifulsoup and I've run into a bit of a problem. Here is a link to the problem page. At the bottom of the list of all of the books, there is some text that reads "Pages" and then a list of numbers which are the page numbers to continue viewing the rest of the books. When each number is clicked it updates the page with a new set of books but when I inspect one of the page number elements all I see is this:
3
I am currently trying to simulate what occurs when you click on one of the numbers and it updates the page with a new set of books. However, I'm not sure how to do this as there is no url link and there is nothing else hinting at how to update the DOM with the new page.
I believe that the site is doing something similar to what this guy did where it was explained that he was essentially using the a tag as a button instead.
If anyone has any other info about what is going on here, I'd be tremendously thankful!
Thanks for the help!

Categories

Resources